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

62

在网站上什么都没做,多天未使用后,尝试登录时出现了这样的错误:

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

主题文档.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 ];
}

我该如何解决这个问题?


你修好了吗?我在这里苦苦挣扎。我尝试回滚Elementor版本,还注释掉了一些代码行... 我可以在Elementor主题编辑器中查看我的页面,但在我的实际网站上,它显示404未找到页面 :( - ib95
5个回答

128

更改代码

$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();
}

通过

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();
    }
}

9
检查代码的人可以发现,OP 只是增加了一个 if 条件语句。 - Ahmed Ali
非常感谢您,先生。您解决了我的难题。 - Desper
编辑插件代码可能会导致在插件升级后错误重新出现。虽然这对我来说有效,但我只是提到这不是最佳实践。 - Fanky
对我有用。错误导致网站的后端和前端都崩溃了。感谢分享。我会在开发中保留这个修改过的文件,以防未来的更新无法纠正此问题。如果您启用了插件的自动更新功能,这可能会非常糟糕。 - vanarie
在我需要编辑的旧版WordPress上,这对我起作用了。 - Patrice Poliquin

32

我类似于Mayous的方法解决了这个问题。我只是将/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php中的一行注释掉了。 因此,第46行是:

$method = $reflection->getMethod( 'get_site_editor_type' );

改为

//$method = $reflection->getMethod( 'get_site_editor_type' );

没起作用。下面有一行使用了$reflection,所以现在会抛出一个错误。 - RedDragonWebDesign
对我来说可以工作。我发现Elementor不断推出有问题的版本非常令人不安。 - Johan
有趣。也许存在两个有缺陷的版本,而这个修复了其中一个有缺陷的版本。 - RedDragonWebDesign
我必须将随后的条件代码(总共4行)注释掉,因为它检查了$method。然后我能够登录。问题出在更新了Elementor免费版本但没有更新Elementor专业版。将Elementor专业版更新到最新版解决了问题,并清除了被注释的代码。 - jbobbins

10

进入路径:/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php

注释掉第47行

$method = $reflection->getMethod( 'get_site_editor_type' );

等待修复后再更新。


1
没起作用。下面有一行使用了$reflection,所以现在会抛出一个错误。 - RedDragonWebDesign

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

嘿,免费版本的版本号是多少?你尝试回滚到任何付费版本了吗? - ib95

1
在我的情况下,网站崩溃了,管理员(已登录用户)无法登录。我的解决方案是关闭“Elementor Pro”(使用我的wp托管的管理控制台),然后我就可以登录并手动上传新版本的Elementor Pro。如果没有禁用插件的方法,我猜编辑代码也可以奏效,只需在以下文件中注释第47行即可:/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接