TYPO3 更新到 11.5.16 和 PHP 8.1 后抛出错误(get_class_methods():参数 #1

问题描述 投票:0回答:2

从 TYPO3 9.5.x LTS 和 PHP 7.4 更新到 TYPO3 11.5.16 和 PHP 8.1 后,我收到此错误:

get_class_methods(): Argument #1 ($object_or_class) must be an object or a valid class name, string given

我知道这是关于我的扩展(当我禁用它时,错误消失),但进一步的调试信息我没有帮助我:

in /html/typo3/typo3_src-11.5.16/typo3/sysext/extbase/Classes/Mvc/ExtbaseRequestParameters.php line 302

            // todo: this is nonsense! We can detect a non existing method in
            // todo: \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin, if necessary.
            // todo: At this point, we want to have a getter for a fixed value.
            $actionMethodName = $this->controllerActionName . 'Action';
            $classMethods = get_class_methods($controllerObjectName);
            if (is_array($classMethods)) {
                foreach ($classMethods as $existingMethodName) {
                    if (strtolower($existingMethodName) === strtolower($actionMethodName)) {
                        $this->controllerActionName = substr($existingMethodName, 0, -6);

我在 github、stackoverflow 或网络上找不到任何内容。其他人也有同样的问题或知道这可能来自哪里吗?

typo3 extbase typo3-11.x
2个回答
6
投票

在这篇文章之后,我想到将 PHP 版本改回 7.4。在 PHP 7.4 中,我收到了不同的错误消息(“类不存在。反射失败。”),这导致我: https://forge.typo3.org/issues/91239

我错误地使用 VendorName 注册插件。以防万一其他人也这样做,我写了这个答案并希望保留这篇文章。


0
投票

我有同样的错误,但原因不同。也许这可以帮助其他与我有同样情况的人。这并不是对原始海报的回答!但这个问题也适合这里。

在文件 localconf.php 中,扩展构建器的表单中输入了拼写错误。

(static function() {
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyExtenson',
    'Show',
    [
        \MyVendor\MyExtenson\Controller\ltemController::class => 'index'
    ],
    // non-cacheable actions
    [
        \MyVendor\MyExtenson\Controller\ltemController::class => 'index'
    ]
);

有一个小写“L”而不是大写“I”。 项目表就是域。 解决方案:

(static function() {
    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
        'MyExtenson',
        'Show',
        [
            \MyVendor\MyExtenson\Controller\ItemController::class => 'index'
        ],
        // non-cacheable actions
        [
            \MyVendor\MyExtenson\Controller\ItemController::class => 'index'
        ]
    );

因此请检查您的文件 ext_localconf.phpExtensionBuilder.json 的拼写是否正确。

© www.soinside.com 2019 - 2024. All rights reserved.