意外的T_PAAMAYIM_NEKUDOTAYIM,期待T_NS_Separator

时间:2012-01-04 22:11:22

标签: php syntax-error

我在周末将应用程序从Ubuntu 11.04(Natty Narwhal)服务器移动到Red Hat Enterprise Linux(RHEL)服务器。我的错误日志中充满了主题行中引用以下函数的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;
}

错误在

中抛出
If (!Namespace::isTalk($ns)

语句。这个错误对我来说是个新错误。我该如何解决?

我将违规代码更改为:

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;

这是否足以修复错误,至少在此文件中?

2 个答案:

答案 0 :(得分:23)

看起来你的新服务器正在运行PHP 5.3,而你的旧服务器运行的是早期版本。

在PHP 5.3中,namespace是关键字,感谢new namespace feature

您现有的Namespace课程需要重命名。当代码尝试将Namespace::isTalk()解析为命名空间名称时,就会发生解析错误。 (这样做的语法类似于namespace Foo;在看到::解析运算符时会感到困惑。)

答案 1 :(得分:3)

PAAMAYIM_NEKUDOTAYIM is the name for the :: (it is Hebrew for twice colon)

检查包含::的所有行,并确保它们都是正确的呼叫。