unclecheese/silverstripe-dropzone

[Question] PHP version compatible

Opened this issue · 6 comments

I use this module for my project, it runs well. But when I install on customer's host, I got the error:

Fatal error: Can't use method return value in write context in /home/***/dropzone/code/FileAttachmentField.php on line 785

I noticed that, the hosting is running with php 5.4.45, and my localhost is running in php 5.5 and above.

So, is it true that this module only compatible with php version >= 5.5 ?

dnpg commented

Having the same issue here. it is related to this function and the way is used:

http://php.net/manual/en/function.empty.php

The required version should be 5.4... because I think it needs the (new Object())->method() syntax. If there is a case of empty() running on an expression, that needs to be changed. It probably got in via a PR.

I wasn't aware of that change in 5.5.. I thought empty() only took vars.

dnpg commented

To fix it you need to take out the postVar request from the empty function and add it to a variable:
Change this
if(empty($files) || empty($request->postVar($name))) {

to:

$var = $request->postVar($name);
if(empty($files) || empty($var)) {

I didn't notice it, either. Thank you @diegopego86 .

That worked for me on 5.4 (I promise to upgrade php soon!)

Will this issue be fixed? Or should I go with the posted solution?