致命错误:未捕获ReflectionException:方法 get_site_editor_type 不存在

Woj*_*ech 63 wordpress elementor

从字面上看,在网站上什么都不做之后,几天没有使用后,尝试登录时,会出现这样的错误:

Fatal error: Uncaught ReflectionException: Method get_site_editor_type does not exist in /usr/home/midas/domains/mydomain.com/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php:45
Run Code Online (Sandbox Code Playgroud)

主题文档.php:

protected static function get_site_editor_type_bc() {
    static $types = [];

    $class_name = static::get_class_full_name();

    $reflection = new \ReflectionClass( $class_name ); //45 line
    $method = $reflection->getMethod( 'get_site_editor_type' );

    // It's own method, use it.
    if ( $class_name === $method->class ) {
        return static::get_site_editor_type();
    }

    // _deprecated_function( 'get_name', '3.0.0', 'get_site_editor_type' );

    // Fallback, get from class instance name (with caching).
    if ( isset( $types[ $class_name ] ) ) {
        return $types[ $class_name ];
    }

    $instance = new static();

    $types[ $class_name ] = $instance->get_name();

    return $types[ $class_name ];
}
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

May*_*ous 131

更改代码

$reflection = new \ReflectionClass( $class_name ); //45 line
$method = $reflection->getMethod( 'get_site_editor_type' );

// It's own method, use it.
if ( $class_name === $method->class ) {
    return static::get_site_editor_type();
}
Run Code Online (Sandbox Code Playgroud)

经过

if (method_exists($class_name, "get_site_editor_type")) {
    $reflection = new \ReflectionClass( $class_name );
    $method = $reflection->getMethod( 'get_site_editor_type' );
    
    // It's own method, use it.
    if ( $class_name === $method->class ) {
        return static::get_site_editor_type();
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 任何逐行检查代码的人,OP 只添加了 if 条件。 (9认同)

小智 33

我和梅尤斯类似地解决了这个问题。我只是注释掉了 中的行/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php。所以第 46 行是

$method = $reflection->getMethod( 'get_site_editor_type' );
Run Code Online (Sandbox Code Playgroud)

改为

//$method = $reflection->getMethod( 'get_site_editor_type' );
Run Code Online (Sandbox Code Playgroud)


小智 10

转到:/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php

注释掉第 47 行

$method = $reflection->getMethod( 'get_site_editor_type' );
Run Code Online (Sandbox Code Playgroud)

等待修复更新。


小智 5

我今天也遇到了这个问题,并通过回滚 Elementor 的免费版本解决了这个问题,这是由于最近更新中的错误造成的。