- الحالة
- محلولة
- أُبلغ عنها لـ
- 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`
- ابحث عن الدالة `flush_cache` حوالي السطر 369. يجب أن ترى هذا الكود:
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(); } }