r84007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84006‎ | r84007 | r84008 >
Date:11:38, 15 March 2011
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Fix bug 27887, caused by r82686: inject session data into FauxRequest s used on save, and pull it out of the FauxRequest object when it is used to generate an inline edit form. This means that tokens are properly propagated when they are generated in inline edit forms and used on the internal edit save.
Modified paths:
  • /trunk/extensions/LiquidThreads/api/ApiThreadAction.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/ParserFunctions.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -353,9 +353,24 @@
354354 $this->output->setArticleBodyOnly( true );
355355 }
356356
 357+ /**
 358+ * Workaround for bugs caused by r82686
 359+ * @param $request FauxRequest object to have session data injected into.
 360+ */
 361+ static function fixFauxRequestSession( $request ) {
 362+ foreach( $_SESSION as $k => $v ) {
 363+ $request->setSessionData( $k, $v );
 364+ }
 365+ }
 366+
357367 static function getInlineEditForm( $talkpage, $method, $operand ) {
358368 $output = new OutputPage;
359369 $request = new FauxRequest( array() );
 370+
 371+ // Workaround for loss of session data when using FauxRequest
 372+ global $wgRequest;
 373+ self::fixFauxRequestSession( $request );
 374+
360375 $title = null;
361376
362377 if ( $talkpage ) {
@@ -377,6 +392,10 @@
378393
379394 $view->doInlineEditForm();
380395
 396+ foreach( $request->getSessionArray() as $k => $v ) {
 397+ $wgRequest->setSessionData( $k, $v );
 398+ }
 399+
381400 return $output->getHTML();
382401 }
383402
Index: trunk/extensions/LiquidThreads/classes/ParserFunctions.php
@@ -135,7 +135,8 @@
136136 $oldOut = $wgOut->getHTML();
137137 $wgOut->clearHTML();
138138
139 - $thread = Threads::withId( $thread );
 139+ $root = new Article( $title );
 140+ $thread = Threads::withRoot( $root );
140141
141142 $view = new LqtView( $wgOut, $article, $title, $wgUser, $wgRequest );
142143
Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -289,6 +289,7 @@
290290 }
291291
292292 $editReq = new FauxRequest( $requestData, true );
 293+ LqtView::fixFauxRequestSession( $editReq );
293294 $internalApi = new ApiMain( $editReq, true );
294295 $internalApi->execute();
295296
@@ -408,6 +409,7 @@
409410 }
410411
411412 $editReq = new FauxRequest( $requestData, true );
 413+ LqtView::fixFauxRequestSession( $editReq );
412414 $internalApi = new ApiMain( $editReq, true );
413415 $internalApi->execute();
414416
@@ -524,6 +526,7 @@
525527 }
526528
527529 $editReq = new FauxRequest( $requestData, true );
 530+ LqtView::fixFauxRequestSession( $editReq );
528531 $internalApi = new ApiMain( $editReq, true );
529532 $internalApi->execute();
530533

Sign-offs

UserFlagDate
Siebrandtested12:05, 15 March 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r96227Specify no oldidwerdna14:19, 4 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82686Use $wgRequest to get and set session items instead of $_SESSION (as for cook...ialex17:54, 23 February 2011

Comments

#Comment by Nikerabbit (talk | contribs)   13:50, 15 March 2011

Are you sure you don't want $root = new Article( $title, 0 );?

+$root = new Article( $title );

Otherwise oldid will mess things up.

#Comment by Nikerabbit (talk | contribs)   09:52, 19 March 2011

I don't know how this is possible but I got it in our error log anyway:

[19-Mar-2011 01:39:06] PHP Notice:  Undefined variable: _SESSION in /www/w/extensions/LiquidThreads/classes/View.php on line 361
[19-Mar-2011 01:39:06] PHP Warning:  Invalid argument supplied for foreach() in /www/w/extensions/LiquidThreads/classes/View.php on line 361
[19-Mar-2011 01:39:06] PHP Fatal error:  Call to a member function getTitle() on a non-object in /www/w/extensions/LiquidThreads/classes/Thread.php on line 1550
#Comment by Werdna (talk | contribs)   14:13, 4 September 2011

Did this ever happen again?

#Comment by Nikerabbit (talk | contribs)   16:41, 4 September 2011

Once, but haven't seen since.

Status & tagging log