Fixed PHP 5.4 compatibility issue with add-on icons

JoeRice

Member
Affected version
2.0.12
After upgrading from 2.0.1 to 2.0.12 I got a warning from the installer that my version of PHP was old and could cause performance and security problems but would still work. After the upgrade a few pages were NOT working including admin.php (with no params) and admin.php?add-ons/

After upgrading PHP from 5.4.16 to 7.1.25 both pages are working fine.

So the bug I'm reporting is that the warning should have been stronger and warned of functional problems.
 
When you say it didn't work, what was the error?

I would have to guess that the fix was either incidental or you had an add-on that was triggering some code that required a higher version.
 
I've identified a bug here which appears to be a subtle behavior change from PHP 5.4 to newer versions surrounding how it caches file metadata for newly created temp files, combined with a bug that didn't handle the add-on icon correctly in certain cases.

These are fixed for 2.0.13, which should eliminate any PHP 5.4-specific issues there, though our recommendation would be to upgrade to a newer PHP anyway (as 2.1 requires that and 5.4 is a long unsupported version).
 
For the benefit of those getting the error, it's along the lines of:
Fatal error: Call to a member function getDataUri() on a non-object in src/XF/AddOn/AddOn.php on line 362
To fix, in src/XF/AddOn/AddOn.php, find:
Code:
File::copyFile($this->getIconPath(), $tempFile, false);
Below it, add this:
Code:
clearstatcache();
 
Back
Top Bottom