WPML
สถานะ
แก้ไขแล้ว
รายงานสำหรับ
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

วิธีแก้ปัญหาชั่วคราว

ใช้ตัวจัดการไฟล์ของโฮสติ้งของคุณ หรือใช้ไคลเอนต์ FTP เช่น Filezilla แล้วไปที่:

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

ปัญหาที่ทราบแล้วทั้งหมด →