Summary
The version of phpThumb that comes with MODX 2.8.6 has a line of code that throws a fatal error in PHP 7.4.
(The phpThumb library is used in the MODX manager to generate the thumbnails in the media browser and the preview for image TVs.)
Step to fix the issue
To fix the issue, remove the word mixed
from this line in the file core/model/phpthumb/phpthumb.class.php
if (!$this->config_disable_debug) {
// if debug mode is enabled, force phpThumbDebug output, do not allow normal thumbnails to be generated
$this->phpThumbDebug = (null === $this->phpThumbDebug ? 9 : max(1, (int) $this->phpThumbDebug));
}
}
public function __destruct() {
$this->purgeTempFiles();
}
public function __set(string $name, mixed $value): void {
}
// public:
public function purgeTempFiles() {
foreach ($this->tempFilesToDelete as $tempFileToDelete) {
if (file_exists($tempFileToDelete)) {
$this->DebugMessage('Deleting temp file "'.$tempFileToDelete.'"', __FILE__, __LINE__);
@unlink($tempFileToDelete);
}
}
Alternatively change the PHP version to at least 8.0.
Related issue on Github
opened 07:53AM - 06 Sep 23 UTC
bug
needs-backport
## Bug report
### Summary
Thumbnails not working in the media browser.

### Step to reproduce
Upload any image (jpg, png) in the media browser, no thumbnails.
### Observed behavior
Trying to navigate the url given in the 'not found' `<img src='/site/connectors/system/phpthumb.php?src=assets%252Fvideo-iframe.png&w=100&h=0&HTTP_MODAUTH=modx64e51c266752a2.30117216_164f338950c1714.28557021&f=png&q=90&wctx=mgr&source=1&t=1693977472&ar=x'>`
I get:
```
Fatal error: Uncaught TypeError: Argument 2 passed to phpthumb::__set() must be an instance of mixed, bool given in
D:\site\site_www\core\vendor\james-heinrich\phpthumb\phpthumb.class.php:321 Stack trace: #0
D:\site\site_www\core\vendor\james-heinrich\phpthumb\phpthumb.class.php(405): phpthumb->__set('cache_source_en...', false) #1
D:\site\site_www\core\src\Revolution\modPhpThumb.php(100): phpthumb->setParameter('cache_source_en...', false) #2
D:\site\site_www\core\src\Revolution\Processors\System\PhpThumb.php(140): MODX\Revolution\modPhpThumb->initialize() #3
D:\site\site_www\core\src\Revolution\Processors\System\PhpThumb.php(84): MODX\Revolution\Processors\System\PhpThumb->loadPhpThumb() #4
D:\site\site_www\core\src\Revolution\Processors\Processor.php(189): MODX\Revolution\Processors\System\PhpThumb->process() #5
D:\site\site_www\core\src\Revolution\modX.php(1761): MOD in
D:\site\site_www\core\vendor\james-heinrich\phpthumb\phpthumb.class.php on line 321
```
Error Log, set to Debug mode:
```
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "prop_file.skipExtensions_desc"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fred"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fredReadOnly"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "prop_file.skipExtensions_desc"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fred"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fredReadOnly"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "prop_file.skipExtensions_desc"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fred"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fredReadOnly"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "prop_file.skipExtensions_desc"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fred"
[2023-09-06 08:32:31] (DEBUG @ D:\site\site_www\core\src\Revolution\modLexicon.php : 526) Language string not found: "fredReadOnly"
[2023-09-06 08:32:31] (WARN @ D:\site\site_www\core\vendor\james-heinrich\phpthumb\phpthumb.class.php : 314) PHP notice: Undefined variable: value
[2023-09-06 08:32:31] (WARN @ D:\site\site_www\core\vendor\james-heinrich\phpthumb\phpthumb.class.php : 314) PHP notice: Undefined variable: value
```
### Expected behavior
Thumbnails should work.
### Environment
3.1.0-dev
PHP 7.4.30
Apache 2.4
Mysql [5.7.17](http://www.mysql.com/)
ModX 2.8.4 works in the same environment as expected.
Environment
MODX 2.8.6-pl
PHP 7.4
4 Likes
The same problem occurs with MODX version 3.0.4.
Step to fix the issue
In MODX 3 the file to change is core/vendor/james-heinrich/phpthumb/phpthumb.class.php
Remove the word mixed
on line 317 (or change the PHP version to at least 8.0).
Environment
MODX 3.0.4-pl
PHP 7.4
3 Likes
It works!
In addition, you must remember to clear the cache and log back into the CMS.
Works for me just by clearing the browser disk cache, without logging out of MODX.