Make Special:NewPages show "originally created as" correctly
authorGeoffreyT2000 <geoffreytrang@gmail.com>
Mon, 7 Aug 2017 15:05:13 +0000 (08:05 -0700)
committerGeoffreyT2000 <geoffreytrang@gmail.com>
Mon, 7 Aug 2017 15:05:13 +0000 (08:05 -0700)
$ret should not be generated until after $oldTitleText is generated. Then "originally created as" will be correctly shown, as expected.

Bug: T171138
Change-Id: Ibcf9f36a46cfc4beb0aaa424e35a334ed73a1c98

includes/specials/SpecialNewpages.php

index 83482f6..f644189 100644 (file)
@@ -382,12 +382,6 @@ class SpecialNewpages extends IncludableSpecialPage {
                # Display the old title if the namespace/title has been changed
                $oldTitleText = '';
                $oldTitle = Title::makeTitle( $result->rc_namespace, $result->rc_title );
-               $ret = "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} "
-                       . "{$tagDisplay} {$oldTitleText}";
-
-               // Let extensions add data
-               Hooks::run( 'NewPagesLineEnding', [ $this, &$ret, $result, &$classes, &$attribs ] );
-               $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
 
                if ( count( $classes ) ) {
                        $attribs['class'] = implode( ' ', $classes );
@@ -402,6 +396,13 @@ class SpecialNewpages extends IncludableSpecialPage {
                        );
                }
 
+               $ret = "{$time} {$dm}{$plink} {$hist} {$dm}{$length} {$dm}{$ulink} {$comment} "
+                       . "{$tagDisplay} {$oldTitleText}";
+
+               // Let extensions add data
+               Hooks::run( 'NewPagesLineEnding', [ $this, &$ret, $result, &$classes, &$attribs ] );
+               $attribs = wfArrayFilterByKey( $attribs, [ Sanitizer::class, 'isReservedDataAttribute' ] );
+
                return Html::rawElement( 'li', $attribs, $ret ) . "\n";
        }