Index: trunk/phase3/includes/Article.php |
— | — | @@ -2110,7 +2110,7 @@ |
2111 | 2111 | $summary = $this->getAutosummary( $oldtext, $text, $flags ); |
2112 | 2112 | } |
2113 | 2113 | |
2114 | | - $editInfo = $this->prepareTextForEdit( $text ); |
| 2114 | + $editInfo = $this->prepareTextForEdit( $text, null, $user ); |
2115 | 2115 | $text = $editInfo->pst; |
2116 | 2116 | $newsize = strlen( $text ); |
2117 | 2117 | |
— | — | @@ -2223,7 +2223,7 @@ |
2224 | 2224 | # as a template. Partly deferred. |
2225 | 2225 | Article::onArticleEdit( $this->mTitle ); |
2226 | 2226 | # 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 ); |
2228 | 2228 | } else { |
2229 | 2229 | # Create new article |
2230 | 2230 | $status->value['new'] = true; |
— | — | @@ -2287,7 +2287,7 @@ |
2288 | 2288 | $dbw->commit(); |
2289 | 2289 | |
2290 | 2290 | # Update links, etc. |
2291 | | - $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, true ); |
| 2291 | + $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, true, $user ); |
2292 | 2292 | |
2293 | 2293 | # Clear caches |
2294 | 2294 | Article::onArticleCreate( $this->mTitle ); |
— | — | @@ -3584,7 +3584,7 @@ |
3585 | 3585 | * Prepare text which is about to be saved. |
3586 | 3586 | * Returns a stdclass with source, pst and output members |
3587 | 3587 | */ |
3588 | | - public function prepareTextForEdit( $text, $revid = null ) { |
| 3588 | + public function prepareTextForEdit( $text, $revid = null, User $user = null ) { |
3589 | 3589 | if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text && $this->mPreparedEdit->revid == $revid ) { |
3590 | 3590 | // Already prepared |
3591 | 3591 | return $this->mPreparedEdit; |
— | — | @@ -3595,7 +3595,7 @@ |
3596 | 3596 | $edit = (object)array(); |
3597 | 3597 | $edit->revid = $revid; |
3598 | 3598 | $edit->newText = $text; |
3599 | | - $edit->pst = $this->preSaveTransform( $text ); |
| 3599 | + $edit->pst = $this->preSaveTransform( $text, $user ); |
3600 | 3600 | $edit->popts = $this->getParserOptions( true ); |
3601 | 3601 | $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid ); |
3602 | 3602 | $edit->oldText = $this->getContent(); |
— | — | @@ -3618,8 +3618,9 @@ |
3619 | 3619 | * @param $timestamp_of_pagechange Timestamp associated with the page change |
3620 | 3620 | * @param $newid Integer: rev_id value of the new revision |
3621 | 3621 | * @param $changed Boolean: Whether or not the content actually changed |
| 3622 | + * @param $user User object: User doing the edit |
3622 | 3623 | */ |
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 ) { |
3624 | 3625 | global $wgDeferredUpdateList, $wgMessageCache, $wgUser, $wgEnableParserCache; |
3625 | 3626 | |
3626 | 3627 | wfProfileIn( __METHOD__ ); |
— | — | @@ -3628,7 +3629,7 @@ |
3629 | 3630 | # Be careful not to double-PST: $text is usually already PST-ed once |
3630 | 3631 | if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { |
3631 | 3632 | wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" ); |
3632 | | - $editInfo = $this->prepareTextForEdit( $text, $newid ); |
| 3633 | + $editInfo = $this->prepareTextForEdit( $text, $newid, $user ); |
3633 | 3634 | } else { |
3634 | 3635 | wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" ); |
3635 | 3636 | $editInfo = $this->mPreparedEdit; |
— | — | @@ -3870,13 +3871,20 @@ |
3871 | 3872 | * so we can do things like signatures and links-in-context. |
3872 | 3873 | * |
3873 | 3874 | * @param $text String article contents |
| 3875 | + * @param $user User object: user doing the edit, $wgUser will be used if |
| 3876 | + * null is given |
3874 | 3877 | * @return string article contents with altered wikitext markup (signatures |
3875 | 3878 | * converted, {{subst:}}, templates, etc.) |
3876 | 3879 | */ |
3877 | | - public function preSaveTransform( $text ) { |
3878 | | - global $wgParser, $wgUser; |
| 3880 | + public function preSaveTransform( $text, User $user = null ) { |
| 3881 | + global $wgParser; |
3879 | 3882 | |
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 ) ); |
3881 | 3889 | } |
3882 | 3890 | |
3883 | 3891 | /* Caching functions */ |