Last modified: 2009-05-27 19:14:04 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T20943, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 18943 - Special:MostLinkedPages gives Fatal error on call to getPrefixedDBkey
Special:MostLinkedPages gives Fatal error on call to getPrefixedDBkey
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Special pages (Other open bugs)
1.16.x
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-27 02:32 UTC by Freek Dijkstra
Modified: 2009-05-27 19:14 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Freek Dijkstra 2009-05-27 02:32:56 UTC
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 );
        }

to:

        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

Regards,
Freek Dijkstra
Comment 1 Alex Z. 2009-05-27 05:01:46 UTC
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.
Comment 2 Niklas Laxström 2009-05-27 05:48:58 UTC
(In reply to comment #1)
> The problem is likely that you have an invalid title in your database
> somewhere.

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

Comment 3 Freek Dijkstra 2009-05-27 14:36:57 UTC
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.

Thanks.
Comment 4 Freek Dijkstra 2009-05-27 18:27:03 UTC
The core of the bug are links to a page itself.

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

  [[#test]]

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.

Thanks.
Comment 5 Niklas Laxström 2009-05-27 19:14:04 UTC
Fixed first part in r51083. The latter is dஉபெ f புக் 17713. See also bug 17751.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links