- Status
- Resolvido
- Relatado para
- WPML Multilingual CMS 3.2.7
- Resolvido em
- 3.3.2
Visão geral do problema
Ao usar a implementação de cache do WPEngine ou outras implementações personalizadas, um erro fatal como este pode aparecer:
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
Isso é causado pelo WPML ao tentar limpar os caches por grupo.
Ao usar o cache padrão fornecido pelo WordPress, isso não é um problema, pois ele usa o método mágico `WP_Object_Cache::__get()`.
No entanto, esse método é usado para ler a propriedade `cache`, que na verdade é privada.
Implementações personalizadas dessa classe podem não ter o método mágico disponível, daí o erro fatal.
Solução alternativa
Como uma solução alternativa temporária, você pode seguir estes passos (leia a nota abaixo):
- Abra o arquivo em `wp-content/plugins/wpml-string-translation/inc/package-translation/inc/wpml-package-translation-helper.class.php`
- Procure o método `flush_cache` por volta da linha 369. Você deve ver este código:
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 ); } } } - Substitua essas linhas por:
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(); } }