r79589 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79588‎ | r79589 | r79590 >
Date:19:08, 4 January 2011
Author:ialex
Status:ok
Tags:
Comment:
Run preSaveTransform() with the user that did the edit, not unconditionally $wgUser
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -2110,7 +2110,7 @@
21112111 $summary = $this->getAutosummary( $oldtext, $text, $flags );
21122112 }
21132113
2114 - $editInfo = $this->prepareTextForEdit( $text );
 2114+ $editInfo = $this->prepareTextForEdit( $text, null, $user );
21152115 $text = $editInfo->pst;
21162116 $newsize = strlen( $text );
21172117
@@ -2223,7 +2223,7 @@
22242224 # as a template. Partly deferred.
22252225 Article::onArticleEdit( $this->mTitle );
22262226 # Update links tables, site stats, etc.
2227 - $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed );
 2227+ $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed, $user );
22282228 } else {
22292229 # Create new article
22302230 $status->value['new'] = true;
@@ -2287,7 +2287,7 @@
22882288 $dbw->commit();
22892289
22902290 # Update links, etc.
2291 - $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, true );
 2291+ $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, true, $user );
22922292
22932293 # Clear caches
22942294 Article::onArticleCreate( $this->mTitle );
@@ -3584,7 +3584,7 @@
35853585 * Prepare text which is about to be saved.
35863586 * Returns a stdclass with source, pst and output members
35873587 */
3588 - public function prepareTextForEdit( $text, $revid = null ) {
 3588+ public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
35893589 if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid ) {
35903590 // Already prepared
35913591 return $this->mPreparedEdit;
@@ -3595,7 +3595,7 @@
35963596 $edit = (object)array();
35973597 $edit->revid = $revid;
35983598 $edit->newText = $text;
3599 - $edit->pst = $this->preSaveTransform( $text );
 3599+ $edit->pst = $this->preSaveTransform( $text, $user );
36003600 $edit->popts = $this->getParserOptions( true );
36013601 $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid );
36023602 $edit->oldText = $this->getContent();
@@ -3618,8 +3618,9 @@
36193619 * @param $timestamp_of_pagechange Timestamp associated with the page change
36203620 * @param $newid Integer: rev_id value of the new revision
36213621 * @param $changed Boolean: Whether or not the content actually changed
 3622+ * @param $user User object: User doing the edit
36223623 */
3623 - public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true ) {
 3624+ public function editUpdates( $text, $summary, $minoredit, $timestamp_of_pagechange, $newid, $changed = true, User $user = null ) {
36243625 global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgEnableParserCache;
36253626
36263627 wfProfileIn( __METHOD__ );
@@ -3628,7 +3629,7 @@
36293630 # Be careful not to double-PST: $text is usually already PST-ed once
36303631 if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
36313632 wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
3632 - $editInfo = $this->prepareTextForEdit( $text, $newid );
 3633+ $editInfo = $this->prepareTextForEdit( $text, $newid, $user );
36333634 } else {
36343635 wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" );
36353636 $editInfo = $this->mPreparedEdit;
@@ -3870,13 +3871,20 @@
38713872 * so we can do things like signatures and links-in-context.
38723873 *
38733874 * @param $text String article contents
 3875+ * @param $user User object: user doing the edit, $wgUser will be used if
 3876+ * null is given
38743877 * @return string article contents with altered wikitext markup (signatures
38753878 * converted, {{subst:}}, templates, etc.)
38763879 */
3877 - public function preSaveTransform( $text ) {
3878 - global $wgParser, $wgUser;
 3880+ public function preSaveTransform( $text, User $user = null ) {
 3881+ global $wgParser;
38793882
3880 - return $wgParser->preSaveTransform( $text, $this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) );
 3883+ if ( $user === null ) {
 3884+ global $wgUser;
 3885+ $user = $wgUser;
 3886+ }
 3887+
 3888+ return $wgParser->preSaveTransform( $text, $this->mTitle, $user, ParserOptions::newFromUser( $user ) );
38813889 }
38823890
38833891 /* Caching functions */

Status & tagging log