Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/94619
Change subject: Avoid fatals in Special:History without parameter
......................................................................
Avoid fatals in Special:History without parameter
Title is not always set meaning this will explode. Use revision
to be safe.
Change-Id: I667f7398e0b99c954b9da827945b12edbc0452c1
---
M includes/specials/SpecialHistory.php
A includes/specials/SpecialMobileContributions.php
2 files changed, 56 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/19/94619/1
diff --git a/includes/specials/SpecialHistory.php
b/includes/specials/SpecialHistory.php
index b838f56..7fc0224 100644
--- a/includes/specials/SpecialHistory.php
+++ b/includes/specials/SpecialHistory.php
@@ -4,7 +4,7 @@
const LIMIT = 50;
protected $mode = 'beta';
- /** @var Title */
+ /** @var Title|null if no title passed */
protected $title;
public function __construct() {
@@ -91,7 +91,7 @@
if ( $canSeeText && $prev && $prev->userCan(
Revision::DELETED_TEXT, $user ) ) {
$diffLink = SpecialPage::getTitleFor( 'MobileDiff',
$prev->getId() )->getLocalUrl();
} elseif ( $canSeeText ) {
- $diffLink = $this->title->getLocalUrl( array( 'oldid'
=> $rev->getId() ) );
+ $diffLink = $rev->getTitle()->getLocalUrl( array(
'oldid' => $rev->getId() ) );
} else {
$diffLink = false;
}
diff --git a/includes/specials/SpecialMobileContributions.php
b/includes/specials/SpecialMobileContributions.php
new file mode 100644
index 0000000..fa124d5
--- /dev/null
+++ b/includes/specials/SpecialMobileContributions.php
@@ -0,0 +1,54 @@
+<?php
+class SpecialMobileContributions extends SpecialHistory {
+ protected $specialPageName = 'Contributions';
+ /** @var User */
+ protected $user;
+
+ public function executeWhenAvailable( $par = '' ) {
+ wfProfileIn( __METHOD__ );
+ $out = $this->getOutput();
+ if ( $par ) {
+ // enter article history view
+ $this->user = User::newFromName( $par );
+ $out->addHtml(
+ Html::openElement( 'div', array( 'class' =>
'page-header-bar' ) ) .
+ Html::openElement( 'div' ) .
+ $this->msg(
'mobile-frontend-contribution-summary', $this->user->getName() )->parse() .
+ Html::closeElement( 'div' ) .
+ Html::closeElement( 'div' )
+ );
+ }
+ $res = $this->doQuery();
+ $this->showHistory( $res );
+ wfProfileOut( __METHOD__ );
+ }
+
+ protected function doQuery() {
+ wfProfileIn( __METHOD__ );
+ $table = 'revision';
+ if ( $this->user ) {
+ $conds = array(
+ 'rev_user' => $this->user->getID(),
+ );
+ } else {
+ $conds = array();
+ }
+ $options = array(
+ 'ORDER BY' => 'rev_timestamp DESC',
+ 'USE INDEX' => 'page_timestamp',
+ );
+
+ $options['LIMIT'] = self::LIMIT + 1;
+
+ $tables = array( $table );
+ $dbr = wfGetDB( DB_SLAVE, $table );
+ $fields = array( '*' );
+
+ wfProfileIn( __METHOD__ . '-query' );
+ $res = $dbr->select( $tables, $fields, $conds, __METHOD__,
$options );
+ wfProfileOut( __METHOD__ . '-query' );
+
+ wfProfileOut( __METHOD__ );
+ return $res;
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/94619
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I667f7398e0b99c954b9da827945b12edbc0452c1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits