Page MenuHomePhabricator

Special:MostLinkedPages gives Fatal error on call to getPrefixedDBkey
Closed, ResolvedPublic


Author: software

Special:MostLinkedPages appears to be broken:

Fatal error: Call to a member function getPrefixedDBkey() on a
non-object in mediawiki/includes/specials/SpecialMostlinked.php on
line 64

This can be fixed by changing the original code:

function makeWlhLink( &$title, $caption, &$skin ) {
        $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
        return $skin->makeKnownLinkObj( $wlh, $caption );


function makeWlhLink( &$title, $caption, &$skin ) {
        $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title );
        return $skin->makeKnownLinkObj( $wlh, $caption );

The bug is currently present in the CVS repository, see /trunk/phase3/includes/specials/SpecialMostlinked.php

Freek Dijkstra

Version: 1.16.x
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:39 PM
bzimport set Reference to bz18943.
bzimport added a subscriber: Unknown Object (MLST).

Worksforme on SVN HEAD (r51042) as well as on Wikipedia - [[Special:MostLinkedPages]]. SpecialPage::getTitleFor() is supposed to take a string as the second parameter and $title should be a Title object there. Passing the Title object directly only works because Title objects can be cast to strings.

The problem is likely that you have an invalid title in your database somewhere.

(In reply to comment #1)

The problem is likely that you have an invalid title in your database

Which we usually try to handle gracefully. php maintenance/cleanupTitles.php should fix it.

software wrote:

Thanks for the feedback. You are right, and now have two separate bugs.

Somehow, the bad title involved is "".
The $title is NULL instead of an object.

Bug 1. Bad titles are not handled gracefully.
Resolution. Please update the code to:

function makeWlhLink( &$title, $caption, &$skin ) {
        if (is_object($title)) {
                $wlh = SpecialPage::getTitleFor( 'Whatlinkshere', $title->getPrefixedDBkey() );
        } else {
                $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
        return $skin->makeKnownLinkObj( $wlh, $caption );

(I usually prefer to write this as try ... catch, but no exception was
raised, so I used an if statement.)

Bug 2. cleanupTitles.php does not detect this case, and the error remains.

I will have to look into this last one, find a solution, put it in a new
bugreport and add the bug ID here.


software wrote:

The core of the bug are links to a page itself.

To replicate, make a page "Sandbox", and make the following intrawiki link:


This will end up in the pagelinks database table as:

pl_namespace = 0
pl_title = ""

The pl_title = "" will cause the Fatal Error in the [[Special:MostLinkedPages]].

This can not be solved in the cleanupTitles.php.
It is a bug in how Mediawiki fills the pagelinks table. I don't know what the exact purpose of this table is, so I'm hesitant to make a fix which make break other things.


Fixed first part in r51083. The latter is dஉபெ f புக் 17713. See also bug 17751.