Index: trunk/phase3/includes/Defines.php |
— | — | @@ -260,6 +260,7 @@ |
261 | 261 | define( 'UTF8_HEAD', false ); |
262 | 262 | define( 'UTF8_TAIL', true ); |
263 | 263 | |
| 264 | +# Hook support constants |
| 265 | +define( 'MW_SUPPORTS_EDITFILTERMERGED', 1 ); |
264 | 266 | |
265 | 267 | |
266 | | - |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -135,6 +135,7 @@ |
136 | 136 | $this->mRevIdFetched = 0; |
137 | 137 | $this->mRedirectUrl = false; |
138 | 138 | $this->mLatest = false; |
| 139 | + $this->mPreparedEdit = false; |
139 | 140 | } |
140 | 141 | |
141 | 142 | /** |
— | — | @@ -1330,7 +1331,8 @@ |
1331 | 1332 | if ($flags & EDIT_AUTOSUMMARY && $summary == '') |
1332 | 1333 | $summary = $this->getAutosummary( $oldtext, $text, $flags ); |
1333 | 1334 | |
1334 | | - $text = $this->preSaveTransform( $text ); |
| 1335 | + $editInfo = $this->prepareTextForEdit( $text ); |
| 1336 | + $text = $editInfo->pst; |
1335 | 1337 | $newsize = strlen( $text ); |
1336 | 1338 | |
1337 | 1339 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -2420,6 +2422,27 @@ |
2421 | 2423 | } |
2422 | 2424 | |
2423 | 2425 | /** |
| 2426 | + * Prepare text which is about to be saved. |
| 2427 | + * Returns a stdclass with source, pst and output members |
| 2428 | + */ |
| 2429 | + function prepareTextForEdit( $text ) { |
| 2430 | + if ( $this->mPreparedEdit && $this->mPreparedEdit->newText == $text ) { |
| 2431 | + // Already prepared |
| 2432 | + return $this->mPreparedEdit; |
| 2433 | + } |
| 2434 | + global $wgParser; |
| 2435 | + $edit = (object)array(); |
| 2436 | + $edit->newText = $text; |
| 2437 | + $edit->pst = $this->preSaveTransform( $text ); |
| 2438 | + $options = new ParserOptions; |
| 2439 | + $options->setTidy( true ); |
| 2440 | + $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $options, true, true ); |
| 2441 | + $edit->oldText = $this->getContent(); |
| 2442 | + $this->mPreparedEdit = $edit; |
| 2443 | + return $edit; |
| 2444 | + } |
| 2445 | + |
| 2446 | + /** |
2424 | 2447 | * Do standard deferred updates after page edit. |
2425 | 2448 | * Update links tables, site stats, search index and message cache. |
2426 | 2449 | * Every 100th edit, prune the recent changes table. |
— | — | @@ -2438,16 +2461,19 @@ |
2439 | 2462 | wfProfileIn( __METHOD__ ); |
2440 | 2463 | |
2441 | 2464 | # Parse the text |
2442 | | - $options = new ParserOptions; |
2443 | | - $options->setTidy(true); |
2444 | | - $poutput = $wgParser->parse( $text, $this->mTitle, $options, true, true, $newid ); |
| 2465 | + # Be careful not to double-PST: $text is usually already PST-ed once |
| 2466 | + if ( !$this->mPreparedEdit ) { |
| 2467 | + $editInfo = $this->prepareTextForEdit( $text ); |
| 2468 | + } else { |
| 2469 | + $editInfo = $this->mPreparedEdit; |
| 2470 | + } |
2445 | 2471 | |
2446 | 2472 | # Save it to the parser cache |
2447 | 2473 | $parserCache =& ParserCache::singleton(); |
2448 | | - $parserCache->save( $poutput, $this, $wgUser ); |
| 2474 | + $parserCache->save( $editInfo->output, $this, $wgUser ); |
2449 | 2475 | |
2450 | 2476 | # Update the links tables |
2451 | | - $u = new LinksUpdate( $this->mTitle, $poutput ); |
| 2477 | + $u = new LinksUpdate( $this->mTitle, $editInfo->output ); |
2452 | 2478 | $u->doUpdate(); |
2453 | 2479 | |
2454 | 2480 | if( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { |
Index: trunk/phase3/includes/EditPage.php |
— | — | @@ -768,7 +768,15 @@ |
769 | 769 | return self::AS_BLANK_ARTICLE; |
770 | 770 | } |
771 | 771 | |
772 | | - $isComment=($this->section=='new'); |
| 772 | + // Run post-section-merge edit filter |
| 773 | + if ( !wfRunHooks( 'EditFilterMerged', array( $this, $this->textbox1, &$this->hookError ) ) ) { |
| 774 | + # Error messages etc. could be handled within the hook... |
| 775 | + wfProfileOut( $fname ); |
| 776 | + return false; |
| 777 | + } |
| 778 | + |
| 779 | + $isComment = ( $this->section == 'new' ); |
| 780 | + |
773 | 781 | $this->mArticle->insertNewArticle( $this->textbox1, $this->summary, |
774 | 782 | $this->minoredit, $this->watchthis, false, $isComment); |
775 | 783 | |
— | — | @@ -843,6 +851,13 @@ |
844 | 852 | |
845 | 853 | $oldtext = $this->mArticle->getContent(); |
846 | 854 | |
| 855 | + // Run post-section-merge edit filter |
| 856 | + if ( !wfRunHooks( 'EditFilterMerged', array( $this, $text, &$this->hookError ) ) ) { |
| 857 | + # Error messages etc. could be handled within the hook... |
| 858 | + wfProfileOut( $fname ); |
| 859 | + return false; |
| 860 | + } |
| 861 | + |
847 | 862 | # Handle the user preference to force summaries here, but not for null edits |
848 | 863 | if( $this->section != 'new' && !$this->allowBlankSummary && $wgUser->getOption( 'forceeditsummary') |
849 | 864 | && 0 != strcmp($oldtext, $text) && !Article::getRedirectAutosummary( $text )) { |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -20,6 +20,10 @@ |
21 | 21 | |
22 | 22 | === Configuration changes in 1.12 === |
23 | 23 | |
| 24 | +=== Removed features in 1.12 === |
| 25 | +* {{REVISIONID}} will no longer give the correct revision ID for current revision |
| 26 | + views. It will still work for history views. |
| 27 | + |
24 | 28 | === New features in 1.12 === |
25 | 29 | * (bug 10735) Add a warning for non-descriptive filenames at Special:Upload |
26 | 30 | * Add {{filepath:}} parser function to get full path to an uploaded file, |