php - MediaWiki upgrade (1.19.6 to 1.22.2) breaks - fetchContent() error

40

Just upgraded Mediawiki 1.19.6 to the most current, 1.22.2. Used update.php, which worked just fine. The front page loads, as do SOME of the articles if you enter their exact URL. However, following any of the links produces:

Catchable fatal error: Argument 1 passed to ContentHandler::getContentText() must implement interface Content, boolean given, called in <wiki path>/includes/Article.php on line 389 and defined in <wiki path>/includes/content/ContentHandler.php on line 95.

I've looked up the call to getContentText() in Article.php, and it's in a function called fetchContent(), with a comment about it being crufty and a note that the ContentHandler method within is deprecated.

I can't figure out how to fix what's gone wrong, and web searches are only turning up bug reports that are marked fixed... any ideas? Thanks very much.

587

Answer

Solution:

getContentText() is depreciated.

Use WikiPage::getContent()

https://doc.wikimedia.org/mediawiki-core/master/php/html/classArticle.html#affd3b52d2544cc334d7805ae9e5aba98

823

Answer

Solution:

We had the same problem. Our ICT guy handled it by adapting the Article.php file placed in the includes directory of your mediawiki. Only 1 function was adapted (line 377 function function fetchContent()). I do not know the exact working principle but the MediaWiki returned to normal.

Also I believe you need to run the mediawiki update routine by visiting: 'HostAdress'/MediaWiki/mw-config/

Original function in Article.php:

function fetchContent() { #BC cruft!
    ContentHandler::deprecated( __METHOD__, '1.21' );

    if ( $this->mContentLoaded && $this->mContent ) {
        return $this->mContent;
    }

    wfProfileIn( __METHOD__ );

    $content = $this->fetchContentObject();

    // @todo Get rid of mContent everywhere!
    $this->mContent = ContentHandler::getContentText( $content );
    ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );

    wfProfileOut( __METHOD__ );

    return $this->mContent;
}

New function in Article.php:

function fetchContent() { #BC cruft!
    ContentHandler::deprecated( __METHOD__, '1.21' );

    if ( $this->mContentLoaded && $this->mContent ) {
        return $this->mContent;
    }

    wfProfileIn( __METHOD__ );

    $content = $this->fetchContentObject();

    if ( !$content ) {
    wfProfileOut( __METHOD__ );
    return false;
    }

    // @todo Get rid of mContent everywhere!
    $this->mContent = ContentHandler::getContentText( $content );
    ContentHandler::runLegacyHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );

    wfProfileOut( __METHOD__ );

    return $this->mContent;
}

People are also looking for solutions to the problem: ajax - PHP action / salesForce

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.