10
votes

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

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?

2
@Charles hehe the error isn't spelled correctly :-PNaftali aka Neal
By the way, the error is actually spelled "PAAMAYIM NEKUDOTAYIM" (helpful for when Googling). As Neal mentions, "PAAMAYIM NEKUDOTAYIM" is Hebrew for double colon (the original authors of PHP were Israeli).Aaron J Spetner
Pfft, I'm a tag facist, not a speeling nazi.Charles
The authors of the Zend Engine were Israeli, Lasmus was not.StevenPatz

2 Answers

23
votes

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

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

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.)

3
votes

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

Check all the lines that contain :: and make sure they are all correct calls.