- סטטוס
- נפתר
- דווח עבור
- 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(); } }