- ステータス
- 解決済み
- 報告対象
- WPML String Translation 3.3.1
- 解決されたバージョン
- WPML String Translation 3.3.2
問題の概要
次のようなエラーが発生する場合があります。
PHP Fatal error: Uncaught TypeError: WPMLStringTranslationInfrastructureStringGettextRepositoryFrontendQueueJsonRepository::get(): Return value must be of type array, null returned in wp-contentpluginswpml-string-translationStringTranslationInfrastructureStringGettextRepositoryFrontendQueueJsonRepository.php:36
Stack trace:
#0 wp-contentpluginswpml-string-translationStringTranslationInfrastructureStringGettextRepositoryFrontendQueueRepository.php(75): WPMLStringTranslationInfrastructureStringGettextRepositoryFrontendQueueJsonRepository->get()
#1 wp-contentpluginswpml-string-translationStringTranslationInfrastructureStringHtmlCommandProcessFrontendGettextStringsQueue.php(34): WPMLStringTranslationInfrastructureStringGettextRepositoryFrontendQueueRepository->get()
.
.
.
#12 {main}
thrown in wp-contentpluginswpml-string-translationStringTranslationInfrastructureStringGettextRepositoryFrontendQueueJsonRepository.php on line 36
回避策
ホスティングのファイルマネージャー、またはFilezillaなどのFTPクライアントを使用して、次のファイルを開きます。
/wp-content/plugins/wpml-string-translation/StringTranslation/Infrastructure/StringGettext/Repository/FrontendQueueJsonRepository.php
以下のコード(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;
}
次のコードに変更します。
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;
}