意外的T_PAAMAYIM_NEKUDOTAYIM,预期为T_NS_Separator [英] Unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_NS_Separator

查看:83
本文介绍了意外的T_PAAMAYIM_NEKUDOTAYIM,预期为T_NS_Separator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 Ubuntu  11.04 (周末将Natty Narwhal)服务器连接到 Red Hat Enterprise Linux (RHEL)服务器.我的错误日志充满了主题行中涉及以下功能的PHP错误:

I moved an application from an Ubuntu 11.04 (Natty Narwhal) Server to a Red Hat Enterprise Linux (RHEL) server over the weekend. My error log is full of the PHP errors in the subject line referencing the following function:

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)

声明.这个错误对我来说是一个新错误.我该怎么解决?

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?

推荐答案

看起来您的新服务器运行的是PHP 5.3,而旧服务器运行的是早期版本.

It looks like your new server is running PHP 5.3, while your old one was running an earlier version.

在PHP 5.3中,由于新名称空间,namespace是一个关键字功能.

In PHP 5.3, namespace is a keyword, thanks to the new namespace feature.

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

Your existing Namespace class is going to need to be renamed. The parse error is occurring as the code tries to resolve Namespace::isTalk() into a namespace name. (The syntax for doing so would be something akin to namespace Foo; it becomes confused at seeing the :: resolution operator.)

这篇关于意外的T_PAAMAYIM_NEKUDOTAYIM,预期为T_NS_Separator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆