- Trạng thái
- Đã giải quyết
- Được báo cáo cho
- WPML String Translation 3.3.1
- Đã giải quyết trong
- WPML String Translation 3.3.2
Tổng quan về lỗi
Bạn có thể gặp phải một lỗi như sau:
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
Giải pháp tạm thời
Sử dụng Trình quản lý tệp trên hosting của bạn hoặc sử dụng phần mềm FTP như Filezilla, hãy truy cập:
/wp-content/plugins/wpml-string-translation/StringTranslation/Infrastructure/StringGettext/Repository/FrontendQueueJsonRepository.php
Tìm đoạn mã này (khoảng dòng 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;
}
Và thay thế bằng đoạn mã này:
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;
}