简体   繁体   English

意外的T_PAAMAYIM_NEKUDOTAYIM,期待T_NS_Separator

[英]Unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_NS_Separator

I moved an application from an Ubuntu 11.04 (Natty Narwhal) Server to a Red Hat Enterprise Linux (RHEL) server over the weekend. 我在周末将应用程序从Ubuntu 11.04 (Natty Narwhal)服务器移动到Red Hat Enterprise Linux (RHEL)服务器。 My error log is full of the PHP errors in the subject line referencing the following function: 我的错误日志中充满了主题行中引用以下函数的PHP错误:

function wfTalkHereArticleFromTitle( &$title, &$article ) {
    global $wgRequest, $wgTalkHereNamespaces;

    if (isset($title->noTalkHere))
        return true; //Stop recursion

    $action    = $wgRequest->getVal( 'action'    );
    $oldid     = $wgRequest->getVal( 'oldid'     );
    $diff      = $wgRequest->getVal( 'diff'      );

    if ($action == 'purge')
        $action = NULL; //"purge" is not considered an action in this context

    if ($action || $oldid || $diff)
        return true;

    $ns = $title->getNamespace();

    if (!Namespace::isTalk($ns) && Namespace::canTalk($ns) && $title->exists()
        && ( !$wgTalkHereNamespaces || in_array($ns, $wgTalkHereNamespaces) ) ) {

        $tns = Namespace::getTalk($ns);
        $talk = Title::makeTitle($tns, $title->getDBKey());

        if ($talk && $talk->userCan('read')) {
            $t = clone $title;
            $t->noTalkHere = true; //Stop recursion

            $a = MediaWiki::articleFromTitle( $t );
            $article = new TalkHereArticle( $a, $talk );
        }
    }
    return true;
}

The error is thrown in the 该错误被抛出

If (!Namespace::isTalk($ns)

statement. 声明。 This error is a new one for me. 这个错误对我来说是个新错误。 How might I resolve it? 我该如何解决?

I changed the offending code to: 我将违规代码更改为:

if ( !Ns::isTalk($ns) && Ns::canTalk($ns) && $title->exists()
    && ( !$wgTalkHereNamespaces || in_array($ns, $wgTalkHereNamespaces) ) ) {

    $tns = Ns::getTalk($ns);
    $talk = Title::makeTitle($tns, $title->getDBKey());

    if ($talk && $talk->userCan('read')) {
        $t = clone $title;
        $t->noTalkHere = true; //Stop recursion

        $a = MediaWiki::articleFromTitle( $t );
        $article = new TalkHereArticle( $a, $talk );
    }
}
return true;

Would that suffice to fix the error, at least in this file? 是否足以修复错误,至少在此文件中?

It looks like your new server is running PHP 5.3, while your old one was running an earlier version. 看起来你的新服务器正在运行PHP 5.3,而你的旧服务器运行的是早期版本。

In PHP 5.3, namespace is a keyword, thanks to the new namespace feature . 在PHP 5.3中,由于新的命名空间功能namespace是一个关键字。

Your existing Namespace class is going to need to be renamed. 您需要重Namespace现有的Namespace类。 The parse error is occurring as the code tries to resolve Namespace::isTalk() into a namespace name. 当代码尝试将Namespace::isTalk()解析为命名空间名称时,发生解析错误。 (The syntax for doing so would be something akin to namespace Foo ; it becomes confused at seeing the :: resolution operator.) (这样做的语法类似于namespace Foo ;它在看到:: resolution运算符时会感到困惑。)

PAAMAYIM_NEKUDOTAYIM is the name for the :: (it is Hebrew for twice colon) PAAMAYIM_NEKUDOTAYIM::的名称(两次冒号是希伯来语)

Check all the lines that contain :: and make sure they are all correct calls. 检查包含::所有行,并确保它们都是正确的调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM