Skip Navigation

Open

Reported for: WPML String Translation 3.3.1

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;
	}



Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>