silverstripe-dropzone icon indicating copy to clipboard operation
silverstripe-dropzone copied to clipboard

[Question] PHP version compatible

Open tungdt-90 opened this issue 7 years ago • 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 ?

tungdt-90 avatar Jul 10 '17 13:07 tungdt-90

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

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

dnpg avatar Jul 13 '17 00:07 dnpg

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.

unclecheese avatar Jul 13 '17 00:07 unclecheese

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)) {

dnpg avatar Jul 13 '17 00:07 dnpg

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

tungdt-90 avatar Jul 13 '17 05:07 tungdt-90

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

tazzydemon avatar Jul 18 '17 01:07 tazzydemon

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

dianavila avatar Feb 15 '18 17:02 dianavila