r93525 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93524‎ | r93525 | r93526 >
Date:14:59, 30 July 2011
Author:ialex
Status:deferred
Tags:
Comment:
* Removed useless global delcaration of $action
* Changed $wgTitle to local title objects
Modified paths:
  • /trunk/extensions/Tasks/Tasks.body.php (modified) (history)
  • /trunk/extensions/Tasks/Tasks.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Tasks/Tasks.body.php
@@ -702,7 +702,7 @@
703703 return true;
704704 }
705705
706 - global $wgOut, $action, $wgRequest, $wgUser;
 706+ global $wgOut, $wgRequest, $wgUser;
707707 $out = '';
708708 $tasks = array();
709709 $wgOut->addLink(array(
@@ -731,7 +731,7 @@
732732
733733 # And ... out!
734734 $returnto = $wgRequest->getVal( 'returnto' );
735 - if( $this->isValidRedirect( $returnto ) ) {
 735+ if( $this->isValidRedirect( $title, $returnto ) ) {
736736 # Forward to other page
737737 $wgOut->redirect( $returnto );
738738
@@ -753,13 +753,12 @@
754754 * @param string $url
755755 * @return bool
756756 */
757 - function isValidRedirect( $url ) {
 757+ function isValidRedirect( $title, $url ) {
758758 if( $url == '' ) {
759759 return false;
760760 }
761761
762 - global $wgTitle;
763 - $url1 = $wgTitle->getFullURL();
 762+ $url1 = $title->getFullURL();
764763 $url1 = explode( '/', $url1 );
765764 $url1 = $url1[0] . '/' . $url1[1] .'/' . $url1[2];
766765 $url2 = explode( '/', $url );
Index: trunk/extensions/Tasks/Tasks.hooks.php
@@ -115,18 +115,24 @@
116116 * Display in sidebar
117117 */
118118 public static function onSkinTemplateToolboxEnd( &$tpl ) { # Checked for HTML and MySQL insertion attacks
119 - global $wgTitle;
120 - if( $wgTitle->isTalkPage() ) {
 119+ if ( method_exists( $tpl, 'getSkin' ) ) {
 120+ $title = $tpl->getSkin()->getTitle();
 121+ } else {
 122+ global $wgTitle;
 123+ $title = $wgTitle;
 124+ }
 125+
 126+ if( $title->isTalkPage() ) {
121127 # No talk pages please
122128 return true;
123129 }
124 - if( $wgTitle->getNamespace() < 0 ) {
 130+ if( $title->getNamespace() < 0 ) {
125131 # No special pages please
126132 return true;
127133 }
128134
129135 $st = new SpecialTasks;
130 - $tasks = $st->get_open_task_list( $wgTitle, true );
 136+ $tasks = $st->get_open_task_list( $title, true );
131137 if( count( $tasks ) == 0 ) {
132138 # No tasks
133139 return true;
@@ -269,13 +275,15 @@
270276 * @return bool true to continue running other hooks, false to abort operation
271277 */
272278 public static function onSkinTemplateNavigation( $skin, &$content_actions ) { # Checked for HTML and MySQL insertion attacks
273 - global $wgTitle, $wgRequest;
 279+ global $wgRequest;
274280
275 - if( $wgTitle->isTalkPage() ) {
 281+ $title = $skin->getTitle();
 282+
 283+ if( $title->isTalkPage() ) {
276284 # No talk pages please
277285 return true;
278286 }
279 - if( $wgTitle->getNamespace() < 0 ) {
 287+ if( $title->getNamespace() < 0 ) {
280288 # No special pages please
281289 return true;
282290 }
@@ -283,7 +291,7 @@
284292 $content_actions['actions']['tasks'] = array(
285293 'class' => ($wgRequest->getVal( 'action', 'view' ) == 'tasks') ? 'selected' : false,
286294 'text' => wfMsgHTML('tasks_tab'),
287 - 'href' => $wgTitle->getLocalUrl( 'action=tasks' )
 295+ 'href' => $title->getLocalUrl( 'action=tasks' )
288296 );
289297 return true;
290298 }

Status & tagging log