WPML
상태
해결됨
보고된 제품
WPML Multilingual CMS 3.2.7
해결된 버전
3.3.2

문제 개요

WPEngine의 캐싱 구현이나 기타 사용자 정의 구현을 사용할 때 다음과 같은 치명적 오류가 발생할 수 있습니다:

PHP Fatal error: Call to undefined method WP_Object_Cache::__get() in /nas/wp/www/cluster-40022/spms/wp-content/plugins/wpml-string-translation/inc/package-translation/inc/wpml-package-translation-helper.class.php on line 384

이는 WPML이 그룹별로 캐시를 플러시하려고 시도하기 때문에 발생합니다.

WordPress에서 제공하는 표준 캐싱을 사용할 때는 `WP_Object_Cache::__get()` 매직 메서드를 사용하므로 이 문제가 발생하지 않습니다.

그러나 이 메서드는 실제로는 비공개인 `cache` 속성을 읽는 데 사용됩니다.

이 클래스의 사용자 정의 구현에는 해당 매직 메서드가 없을 수 있으며, 이로 인해 치명적 오류가 발생합니다.

임시 해결 방법

임시 해결 방법으로 다음 단계를 따르세요(하단의 참고 사항을 읽어보세요).


  • `wp-content/plugins/wpml-string-translation/inc/package-translation/inc/wpml-package-translation-helper.class.php` 파일을 여세요.

  • 369번째 줄 부근에서 `flush_cache` 메서드를 찾으세요. 다음과 같은 코드가 표시됩니다.
    final private function flush_cache() {
    	/** @var WP_Object_Cache $wp_object_cache */
    	global $wp_object_cache;
    	$cache = $wp_object_cache->__get( 'cache' );
    	if ( isset( $cache[ $this->cache_group ] ) ) {
    		foreach ( $cache[ $this->cache_group ] as $cache_key => $data ) {
    			wp_cache_delete( $cache_key, $this->cache_group );
    		}
    	}
    }

  • 이 줄을 다음 코드로 교체하세요.
    final private function flush_cache() {
    	/** @var WP_Object_Cache $wp_object_cache */
    	global $wp_object_cache;
    	$has_cache_property = method_exists( $wp_object_cache, '__get' );
    	if ( ! $has_cache_property && property_exists( $wp_object_cache, 'cache' ) ) {
    		$reflector          = new ReflectionClass( get_class( $wp_object_cache ) );
    		$cache_property     = $reflector->getProperty( 'cache' );
    		$has_cache_property = $cache_property->isPublic();
    	}
    	if ( $has_cache_property ) {
    		$cache = $wp_object_cache->cache;
    		if ( isset( $cache[ $this->cache_group ] ) ) {
    			foreach ( $cache[ $this->cache_group ] as $cache_key => $data ) {
    				wp_cache_delete( $cache_key, $this->cache_group );
    			}
    		}
    	} else {
    		wp_cache_flush();
    	}
    }
참고: 이 기능은 전체 캐시가 아닌 캐시의 일부를 지우는 데 필수입니다. 이 임시 해결 방법을 사용하면 캐시 비우기가 전역으로 발생하므로 성능에 영향을 미칠 수 있습니다. 그러나 이 특정 코드는 문자열 패키지를 삭제하거나 업데이트할 때(예: Layouts 또는 Gravity Forms)만 실행됩니다.

알려진 모든 문제 →