Issue with TinyMCE Moxiemanager on PHP8

886 Views Asked by At

We are using Moxiemanager with TinyMCE. But after upgrading on PHP8 we are facing error. We are getting the following error -

Server returned an invalid response
Fatal error: During inheritance of IteratorAggregate: Uncaught MOXMAN_Exception: Return type of MOXMAN_Vfs_FileList::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/Vfs/FileList.php:38 Stack trace: #0 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/Vfs/FileList.php(13): MOXMAN_Exception::throwRuntimeError() #1 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/AutoLoader.php(77): require('/sites/ssc.lara...') #2 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/Vfs/Local/File.php(277): MOXMAN_AutoLoader::autoload() #3 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/Commands/ListFilesCommand.php(148): MOXMAN_Vfs_Local_File->listFilesFiltered() #4 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/CommandCollection.php(39): MOXMAN_Commands_ListFilesCommand->execute() #5 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/CorePlugin.php(69): MOXMAN_CommandCollection->execute() #6 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/Handlers/JsonRpcHandler.php(74): MOXMAN_CorePlugin->execute() #7 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/CorePlugin.php(82): MOXMAN_Handlers_JsonRpcHandler->processRequest() #8 /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/api.php(18): MOXMAN_CorePlugin->processRequest() #9 {main} in /sites/ssc.lara/ssc/public/assets/libs/tinymce/plugins/moxiemanager/classes/Vfs/FileList.php on line 13
Ok

It seems to be some issue with PHP's Iterator implementation. Can anyone help?

3

There are 3 best solutions below

3
Tiny Lincoln On

MoxieManager is does not support PHP 8 at this time. Moxie's developers are working on including PHP 8 support, and hope to have that release available later in Q1 2022.

Source: I work at Tiny

1
noobeveryday On

At tinymce\plugins\moxiemanager\classes\Util\NameValueCollection.php, change:

public function getIterator() {
    return new ArrayIterator($this->items);
}

to:

public function getIterator(): \Traversable {
    return new \ArrayIterator($this->items);
}

And at tinymce/plugins/moxiemanager/classes/Vfs/FileList.php, change:

public function getIterator() {
    return new ArrayIterator($this->getFiles());
}

to:

public function getIterator(): \Traversable {
    return new \ArrayIterator($this->items);
}

After these changes my Moxiemanager works fine (ver 2.1.8-28, PHP 8.1.8).

0
tokstar On

For php8.1, at tinymce/plugins/moxiemanage/classes/util/PDO.php I had to add

#[\ReturnTypeWillChange]

to prepare and exec function in PDO.php. It works on php8.1.