phpThumb issue with ModX 2.8.6 and PHP 5.6

Firstly I know we shouldn’t be using PHP5.x, so let’s just leave that at the door for a moment.

I recently upgraded to modx 2.8.6 and found that for some reason, some resources were throwing an error 500. The modx system error log offered nothing at all (no errors written to the log) which I thought was odd.

I did some digging and finally came across some entries in my httpd error log which offered some clues. It was coming up with


PHP Parse error:  syntax error, unexpected ':', expecting ';' or '{' in /path/to/site/core/model/phpthumb/phpthumb.class.php on line 317

Looking in that file, there’s

	public function __set(string $name, mixed $value): void {
	}

I found if you change it to the below, that does the trick

	public function __set(string $name, mixed $value) {
	}

I hope someone finds this useful but you aren’t completely out of the woods because it’s still throwing these errors:

[2023-11-15 13:28:29] (ERROR @  /path/to/site/core/model/phpthumb/phpthumb.class.php : 317) Recoverable error: Argument 1 passed to phpthumb::__set() must be an instance of string, string given
[2023-11-15 13:28:29] (ERROR @  /path/to/site/core/model/phpthumb/phpthumb.class.php : 317) Recoverable error: Argument 2 passed to phpthumb::__set() must be an instance of mixed, boolean given

According to W3techs, ~20% of websites running PHP still uses PHP5. That’s going to be millions of sites in reality so suggest that this package is fixed for backwards compatibility in the next update.

This problem is related to this issue with PHP 7.4:

I did create a pull request on Github that fixes the problem for PHP 7.4.

This pull request won’t fix the (different) error in PHP 5.6.
Create another pull request if you want it fixed.

I’m not a dev, so I won’t be doing that but someone probably should open a bug report

Just FYI, 500 errors are server-level errors and will never be logged in the MODX error log. Always look for them in the server log.

1 Like