Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -97,17 +97,17 @@ |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Checks some initial queries |
101 | | - * Note that $title here is *not* a Title object, but a string! |
102 | 101 | * |
103 | | - * @param $title String |
104 | | - * @param $action String |
| 102 | + * @param $request WebRequest |
105 | 103 | * @return Title object to be $wgTitle |
106 | 104 | */ |
107 | | - function checkInitialQueries( $title, $action ) { |
108 | | - global $wgRequest, $wgContLang; |
| 105 | + function checkInitialQueries( WebRequest $request ) { |
| 106 | + global $wgContLang; |
109 | 107 | |
110 | | - $curid = $wgRequest->getInt( 'curid' ); |
111 | | - if( $wgRequest->getCheck( 'search' ) ) { |
| 108 | + $curid = $request->getInt( 'curid' ); |
| 109 | + $title = $request->getVal( 'title' ); |
| 110 | + |
| 111 | + if( $request->getCheck( 'search' ) ) { |
112 | 112 | // Compatibility with old search URLs which didn't use Special:Search |
113 | 113 | // Just check for presence here, so blank requests still |
114 | 114 | // show the search page when using ugly URLs (bug 8054). |
— | — | @@ -115,7 +115,7 @@ |
116 | 116 | } elseif( $curid ) { |
117 | 117 | // URLs like this are generated by RC, because rc_title isn't always accurate |
118 | 118 | $ret = Title::newFromID( $curid ); |
119 | | - } elseif( $title == '' && $action != 'delete' ) { |
| 119 | + } elseif( $title == '' && $this->getAction( $request ) != 'delete' ) { |
120 | 120 | $ret = Title::newMainPage(); |
121 | 121 | } else { |
122 | 122 | $ret = Title::newFromURL( $title ); |
— | — | @@ -127,8 +127,8 @@ |
128 | 128 | // For non-special titles, check for implicit titles |
129 | 129 | if( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) { |
130 | 130 | // We can have urls with just ?diff=,?oldid= or even just ?diff= |
131 | | - $oldid = $wgRequest->getInt( 'oldid' ); |
132 | | - $oldid = $oldid ? $oldid : $wgRequest->getInt( 'diff' ); |
| 131 | + $oldid = $request->getInt( 'oldid' ); |
| 132 | + $oldid = $oldid ? $oldid : $request->getInt( 'diff' ); |
133 | 133 | // Allow oldid to override a changed or missing title |
134 | 134 | if( $oldid ) { |
135 | 135 | $rev = Revision::newFromId( $oldid ); |
— | — | @@ -173,8 +173,6 @@ |
174 | 174 | function handleSpecialCases( &$title, &$output, $request ) { |
175 | 175 | wfProfileIn( __METHOD__ ); |
176 | 176 | |
177 | | - $action = $this->getVal( 'Action' ); |
178 | | - |
179 | 177 | // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. |
180 | 178 | if( is_null($title) || ( ( $title->getDBkey() == '' ) && ( $title->getInterwiki() == '' ) ) ) { |
181 | 179 | $title = SpecialPage::getTitleFor( 'Badtitle' ); |
— | — | @@ -202,7 +200,7 @@ |
203 | 201 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
204 | 202 | } |
205 | 203 | // Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant |
206 | | - } else if ( $action == 'view' && !$request->wasPosted() |
| 204 | + } else if ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted() |
207 | 205 | && ( $request->getVal( 'title' ) === null || $title->getPrefixedDBKey() != $request->getText( 'title' ) ) |
208 | 206 | && !count( array_diff( array_keys( $request->getValues() ), array( 'action', 'title' ) ) ) ) |
209 | 207 | { |
— | — | @@ -284,6 +282,41 @@ |
285 | 283 | } |
286 | 284 | |
287 | 285 | /** |
| 286 | + * Returns the action that will be executed, not necesserly the one passed |
| 287 | + * passed through the "action" parameter. Actions disabled in |
| 288 | + * $wgDisabledActions will be replaced by "nosuchaction" |
| 289 | + * |
| 290 | + * @param $request WebRequest |
| 291 | + * @return String: action |
| 292 | + */ |
| 293 | + public function getAction( WebRequest $request ) { |
| 294 | + global $wgDisabledActions; |
| 295 | + |
| 296 | + $action = $request->getVal( 'action', 'view' ); |
| 297 | + |
| 298 | + // Check for disabled actions |
| 299 | + if( in_array( $action, $wgDisabledActions ) ) { |
| 300 | + return 'nosuchaction'; |
| 301 | + } |
| 302 | + |
| 303 | + // Workaround for bug #20966: inability of IE to provide an action dependent |
| 304 | + // on which submit button is clicked. |
| 305 | + if ( $action === 'historysubmit' ) { |
| 306 | + if ( $request->getBool( 'revisiondelete' ) ) { |
| 307 | + return 'revisiondelete'; |
| 308 | + } elseif ( $request->getBool( 'revisionmove' ) ) { |
| 309 | + return 'revisionmove'; |
| 310 | + } else { |
| 311 | + return 'view'; |
| 312 | + } |
| 313 | + } elseif ( $action == 'editredlink' ) { |
| 314 | + return 'edit'; |
| 315 | + } |
| 316 | + |
| 317 | + return $action; |
| 318 | + } |
| 319 | + |
| 320 | + /** |
288 | 321 | * Initialize the object to be known as $wgArticle for "standard" actions |
289 | 322 | * Create an Article object for the page, following redirects if needed. |
290 | 323 | * |
— | — | @@ -295,7 +328,7 @@ |
296 | 329 | function initializeArticle( &$title, &$output, $request ) { |
297 | 330 | wfProfileIn( __METHOD__ ); |
298 | 331 | |
299 | | - $action = $this->getVal( 'action', 'view' ); |
| 332 | + $action = $request->getVal( 'action', 'view' ); |
300 | 333 | $article = self::articleFromTitle( $title ); |
301 | 334 | // NS_MEDIAWIKI has no redirects. |
302 | 335 | // It is also used for CSS/JS, so performance matters here... |
— | — | @@ -439,24 +472,8 @@ |
440 | 473 | return; |
441 | 474 | } |
442 | 475 | |
443 | | - $action = $this->getVal( 'Action' ); |
444 | | - if( in_array( $action, $this->getVal( 'DisabledActions', array() ) ) ) { |
445 | | - /* No such action; this will switch to the default case */ |
446 | | - $action = 'nosuchaction'; |
447 | | - } |
| 476 | + $action = $this->getAction( $request ); |
448 | 477 | |
449 | | - // Workaround for bug #20966: inability of IE to provide an action dependent |
450 | | - // on which submit button is clicked. |
451 | | - if ( $action === 'historysubmit' ) { |
452 | | - if ( $request->getBool( 'revisiondelete' ) ) { |
453 | | - $action = 'revisiondelete'; |
454 | | - } elseif ( $request->getBool( 'revisionmove' ) ) { |
455 | | - $action = 'revisionmove'; |
456 | | - } else { |
457 | | - $action = 'view'; |
458 | | - } |
459 | | - } |
460 | | - |
461 | 478 | switch( $action ) { |
462 | 479 | case 'view': |
463 | 480 | $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
— | — | @@ -511,7 +528,6 @@ |
512 | 529 | } |
513 | 530 | /* Continue... */ |
514 | 531 | case 'edit': |
515 | | - case 'editredlink': |
516 | 532 | if( wfRunHooks( 'CustomEditor', array( $article, $user ) ) ) { |
517 | 533 | $internal = $request->getVal( 'internaledit' ); |
518 | 534 | $external = $request->getVal( 'externaledit' ); |
Index: trunk/phase3/index.php |
— | — | @@ -50,15 +50,13 @@ |
51 | 51 | exit; |
52 | 52 | } |
53 | 53 | |
54 | | -# Query string fields |
55 | | -$action = $wgRequest->getVal( 'action', 'view' ); |
56 | | -$title = $wgRequest->getVal( 'title' ); |
57 | | - |
58 | 54 | # Set title from request parameters |
59 | | -$wgTitle = $mediaWiki->checkInitialQueries( $title, $action ); |
| 55 | +$wgTitle = $mediaWiki->checkInitialQueries( $wgRequest ); |
60 | 56 | |
61 | 57 | wfProfileOut( 'main-misc-setup' ); |
62 | 58 | |
| 59 | +$action = $wgRequest->getVal( 'action' ); |
| 60 | + |
63 | 61 | # Send Ajax requests to the Ajax dispatcher. |
64 | 62 | if( $wgUseAjax && $action == 'ajax' ) { |
65 | 63 | $dispatcher = new AjaxDispatcher(); |
— | — | @@ -94,8 +92,6 @@ |
95 | 93 | } |
96 | 94 | |
97 | 95 | # Setting global variables in mediaWiki |
98 | | -$mediaWiki->setVal( 'action', $action ); |
99 | | -$mediaWiki->setVal( 'DisabledActions', $wgDisabledActions ); |
100 | 96 | $mediaWiki->setVal( 'DisableHardRedirects', $wgDisableHardRedirects ); |
101 | 97 | $mediaWiki->setVal( 'EnableCreativeCommonsRdf', $wgEnableCreativeCommonsRdf ); |
102 | 98 | $mediaWiki->setVal( 'EnableDublinCoreRdf', $wgEnableDublinCoreRdf ); |
Index: trunk/extensions/Lockdown/Lockdown.php |
— | — | @@ -119,7 +119,7 @@ |
120 | 120 | function lockdownMediawikiPerformAction ( $output, $article, $title, $user, $request, $wiki ) { |
121 | 121 | global $wgActionLockdown; |
122 | 122 | |
123 | | - $action = $request->getVal( 'action', 'view' ); |
| 123 | + $action = $wiki->getAction( $request ); |
124 | 124 | |
125 | 125 | if ( !isset( $wgActionLockdown[$action] ) ) return true; |
126 | 126 | |
Index: trunk/extensions/InlineEditor/InlineEditor.class.php |
— | — | @@ -19,19 +19,15 @@ |
20 | 20 | * Checks whether or not to spawn the editor, and does so if nessicary. |
21 | 21 | */ |
22 | 22 | public static function mediaWikiPerformAction( $output, $article, $title, $user, $request, $wiki ) { |
23 | | - global $wgHooks, $wgDisabledActions; |
| 23 | + global $wgHooks; |
24 | 24 | |
25 | | - // the action of the page, i.e. 'view' or 'edit' |
26 | | - $action = $request->getVal( 'action', 'view' ); |
27 | | - |
28 | 25 | // check if the editor could be used on this page, and if so, hide the [edit] links |
29 | 26 | if ( self::isValidBrowser() && !self::isAdvancedPage( $article, $title ) ) { |
30 | 27 | self::hideEditSection( $output ); |
31 | 28 | } |
32 | 29 | |
33 | 30 | // return if the action is not 'edit' or if it's disabled |
34 | | - if ( $action != 'edit' || in_array( $action, $wgDisabledActions ) ) |
35 | | - { |
| 31 | + if ( $wiki->getAction( $request ) != 'edit' ) { |
36 | 32 | return true; |
37 | 33 | } |
38 | 34 | |
Index: trunk/extensions/InputBox/InputBox.hooks.php |
— | — | @@ -52,8 +52,7 @@ |
53 | 53 | $request, |
54 | 54 | $wiki ) |
55 | 55 | { |
56 | | - $action = $request->getVal( 'action', 'view' ); |
57 | | - if( $action !== 'edit' ){ |
| 56 | + if( $wiki->getAction( $request ) !== 'edit' ){ |
58 | 57 | # not our problem |
59 | 58 | return true; |
60 | 59 | } |