Resolved
Reported for: WPML String Translation 3.3.1
Resolved in: WPML String Translation 3.3.2
Overview of the issue
You might encounter an error like this one:
PHP Fatal error: Uncaught TypeError: WPML\StringTranslation\Infrastructure\StringGettext\Repository\FrontendQueueJsonRepository::get(): Return value must be of type array, null returned in \wp-content\plugins\wpml-string-translation\StringTranslation\Infrastructure\StringGettext\Repository\FrontendQueueJsonRepository.php:36 Stack trace: #0 \wp-content\plugins\wpml-string-translation\StringTranslation\Infrastructure\StringGettext\Repository\FrontendQueueRepository.php(75): WPML\StringTranslation\Infrastructure\StringGettext\Repository\FrontendQueueJsonRepository->get() #1 \wp-content\plugins\wpml-string-translation\StringTranslation\Infrastructure\StringHtml\Command\ProcessFrontendGettextStringsQueue.php(34): WPML\StringTranslation\Infrastructure\StringGettext\Repository\FrontendQueueRepository->get() . . . #12 {main} thrown in \wp-content\plugins\wpml-string-translation\StringTranslation\Infrastructure\StringGettext\Repository\FrontendQueueJsonRepository.php on line 36
Workaround
Using your hosting’s File manager or using an FTP client like Filezilla, Go to:
/wp-content/plugins/wpml-string-translation/StringTranslation/Infrastructure/StringGettext/Repository/FrontendQueueJsonRepository.php
Find this code (around line 28):
public function get(): array { $filepath = $this->getQueueFilepath(); $data = []; if ( file_exists( $filepath ) && is_readable( $filepath ) ) { $data = json_decode( file_get_contents( $filepath ), true ); } return $data; }
And change it with this one:
public function get(): array { $filepath = $this->getQueueFilepath(); $data = []; if ( file_exists( $filepath ) && is_readable( $filepath ) ) { $data = json_decode( file_get_contents( $filepath ), true ); } if( is_null($data)){ $data = []; } return $data; }
Thank you. Will it be this fix on the next update?
Hi Heriberto,
This issue has already been fixed. Please make sure you’re using the latest versions of WPML and String Translation.
If the problem persists, feel free to open a ticket on our support forum, we will be happy to help you.