(bug 39062) Show revs without rev_parent_id in Special:Contributions.
authorBrian Wolff <bawolff+wn@gmail.com>
Thu, 27 Dec 2012 07:28:17 +0000 (03:28 -0400)
committerBrian Wolff <bawolff+wn@gmail.com>
Sat, 29 Dec 2012 05:07:58 +0000 (01:07 -0400)
This is a follow-up to Ifd63cdf1 (c8e0ec3f)

Currently if rev_parent_id is not populated on a row we just
output an empty bullet - <li class=""></li>. (Which can
happen if an update is performed properly. There are (were?) some
examples of this on en wikipedia. I was just talking to a user
who had some of his revisions not be populated for that field,
so it can happen.) Heck there's even code that checks for this
case inside the if statement (before this commit) that stops
non rev_parent_id rows from being processed.

This seems very very wrong to me. Change the check for if a revision
is valid to look for rev_id (which is the primary key, so
going to be there, and always has been there).

Also in the
case we don't have a valid revision and can't format it
(For example, an ext made a hook that added random rows
to the Special:Contribs query, but forgot to format some),
instead of outputting an empty bullet, output just an
html comment, (and a debug log entry).

Thank you to Isarra for reporting this issue.

Change-Id: I7ef562d6e829877dd8ea4ffb1e7e04b46c943ec1

RELEASE-NOTES-1.21
includes/specials/SpecialContributions.php

index e04cb8e..6859bda 100644 (file)
@@ -125,6 +125,8 @@ production.
   History page.
 * (bug 42949) API no longer assumes all exceptions are MWException.
 * (bug 41733) Hide "New user message" (.usermessage) element from printable view.
+* (bug 39062) Special:Contributions will display changes that don't have
+  a parent id instead of just an empty bullet item.
 
 === API changes in 1.21 ===
 * prop=revisions can now report the contentmodel and contentformat.
index c58d4da..b6fea02 100644 (file)
@@ -827,7 +827,7 @@ class ContribsPager extends ReverseChronologicalPager {
                 */
                wfSuppressWarnings();
                $rev = new Revision( $row );
-               $validRevision = $rev->getParentId() !== null;
+               $validRevision = (bool) $rev->getId();
                wfRestoreWarnings();
 
                if ( $validRevision ) {
@@ -947,7 +947,12 @@ class ContribsPager extends ReverseChronologicalPager {
                wfRunHooks( 'ContributionsLineEnding', array( $this, &$ret, $row, &$classes ) );
 
                $classes = implode( ' ', $classes );
-               $ret = "<li class=\"$classes\">$ret</li>\n";
+               if ( $classes === '' && $ret === '' ) {
+                       wfDebug( 'Dropping Special:Contribution row that could not be formatted' );
+                       $ret = "<!-- Could not format Special:Contribution row. -->\n";
+               } else {
+                       $ret = "<li class=\"$classes\">$ret</li>\n";
+               }
 
                wfProfileOut( __METHOD__ );
                return $ret;