- Estado
- Resuelto
- Notificado para
- WPML Multilingual CMS 3.2.7
- Resuelto en
- 3.3.2
Resumen del problema
Al usar la implementación de caché de WPEngine u otras implementaciones personalizadas, puede aparecer un error fatal como este:
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
Esto se debe a que WPML intenta vaciar las cachés por grupo.
Al usar la caché estándar proporcionada por WordPress, esto no es un problema, ya que utiliza el método mágico `WP_Object_Cache::__get()`.
Sin embargo, este método se utiliza para leer la propiedad `cache`, que en realidad es privada.
Las implementaciones personalizadas de esta clase pueden no tener disponible el método mágico, de ahí el error fatal.
Solución alternativa
Como solución alternativa temporal, puede seguir estos pasos (lea la nota al final):
- Abra el archivo en `wp-content/plugins/wpml-string-translation/inc/package-translation/inc/wpml-package-translation-helper.class.php`
- Busque el método `flush_cache` alrededor de la línea 369. Debería 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 ); } } } - Reemplace estas líneas con:
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(); } }