r51879 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51878‎ | r51879 | r51880 >
Date:10:45, 15 June 2009
Author:jojo
Status:ok
Tags:
Comment:
check result from Title::newFromText()
Modified paths:
  • /trunk/extensions/Collection/Collection.body.php (modified) (history)
  • /trunk/extensions/Collection/Collection.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.hooks.php
@@ -159,7 +159,7 @@
160160 // the "subpage" (i.e. "par") part has been stripped off by SpecialPage.php
161161 // in $wgTitle.
162162 $origTitle = Title::newFromText($wgRequest->getVal('title'));
163 - if( !is_null( $origTitle )
 163+ if( $origTitle
164164 && $origTitle->getLocalUrl() == SkinTemplate::makeSpecialUrl( 'Book' ) ) {
165165 return;
166166 }
Index: trunk/extensions/Collection/Collection.body.php
@@ -55,9 +55,11 @@
5656 self::limitExceeded();
5757 return;
5858 }
59 - $title_url = $wgRequest->getVal( 'arttitle', '' );
6059 $oldid = $wgRequest->getInt( 'oldid', 0 );
61 - $title = Title::newFromText( $title_url );
 60+ $title = Title::newFromText( $wgRequest->getVal( 'arttitle', '' ) );
 61+ if ( !$title ) {
 62+ return;
 63+ }
6264 $this->addArticle( $title, $oldid );
6365 if ( $oldid == 0 ) {
6466 $redirectURL = $title->getFullURL();
@@ -68,9 +70,11 @@
6971 $wgOut->redirect( $redirectURL );
7072 return;
7173 case 'remove_article/':
72 - $title_url = $wgRequest->getVal( 'arttitle', '' );
7374 $oldid = $wgRequest->getInt( 'oldid', 0 );
74 - $title = Title::newFromText( $title_url );
 75+ $title = Title::newFromText( $wgRequest->getVal( 'arttitle', '' ) );
 76+ if ( !$title ) {
 77+ return;
 78+ }
7579 self::removeArticle( $title, $oldid );
7680 if ( $oldid == 0 ) {
7781 $redirectURL = $title->getFullURL();
@@ -87,7 +91,7 @@
8892 $redirectURL = SkinTemplate::makeSpecialUrl( 'Book' );
8993 if ( !empty( $redirect ) ) {
9094 $title = Title::newFromText( $redirect );
91 - if ( !is_null( $title ) ) {
 95+ if ( $title ) {
9296 $redirectURL = $title->getFullURL();
9397 }
9498 }
@@ -125,6 +129,9 @@
126130 return;
127131 case 'load_collection/':
128132 $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) );
 133+ if ( !$title ) {
 134+ return;
 135+ }
129136 if ( $wgRequest->getVal( 'cancel' ) ) {
130137 $wgOut->redirect( $title->getFullURL() );
131138 return;
@@ -144,6 +151,9 @@
145152 return;
146153 case 'order_collection/':
147154 $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ) );
 155+ if ( !$title ) {
 156+ return;
 157+ }
148158 $collection = $this->loadCollection( $title );
149159 $partner = $wgRequest->getVal( 'partner', 'pediapress' );
150160 return $this->postZIP( $collection, $partner );
@@ -172,7 +182,7 @@
173183 wfMsgForContent( 'coll-collections' ) . '/' . $collname
174184 );
175185 }
176 - if ( !isset( $title ) ) {
 186+ if ( !$title ) {
177187 return;
178188 }
179189 if ( $this->saveCollection( $title, $wgRequest->getBool( 'overwrite' ) ) ) {
@@ -200,10 +210,16 @@
201211 return $this->download();
202212 case 'render_article/':
203213 $title = Title::newFromText( $wgRequest->getVal( 'arttitle', '' ) );
 214+ if ( !$title ) {
 215+ return;
 216+ }
204217 $oldid = $wgRequest->getInt( 'oldid', 0 );
205218 return $this->renderArticle( $title, $oldid, $wgRequest->getVal( 'writer', 'rl' ) );
206219 case 'render_collection/':
207220 $title = Title::newFromText( $wgRequest->getVal( 'colltitle', '' ));
 221+ if ( !$title ) {
 222+ return;
 223+ }
208224 $collection = $this->loadCollection( $title );
209225 if ( $collection ) {
210226 $this->renderCollection( $collection, $title, $wgRequest->getVal( 'writer', 'rl' ) );
@@ -501,7 +517,7 @@
502518
503519
504520 $articleTitle = Title::newFromText( $articleTitle );
505 - if( is_null( $articleTitle ) ) {
 521+ if( !$articleTitle ) {
506522 continue;
507523 }
508524 if ($oldid < 0) {

Status & tagging log