r24230 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24229‎ | r24230 | r24231 >
Date:08:49, 18 July 2007
Author:aaron
Status:old
Tags:
Comment:
*Decrappify inefficient hook/link update scheme for this extension
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php (modified) (history)
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/LinksUpdate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -469,6 +469,9 @@
470470 &$result: Set this and return false to override the internal checks
471471 $user: User the password is being validated for
472472
 473+'LinksUpdateConstructed': At the end of LinksUpdate() is contruction.
 474+&$linksUpdate: the LinkUpdate object
 475+
473476 'LoginAuthenticateAudit': a login attempt for a valid user account either succeeded or failed.
474477 No return data is accepted; this hook is for auditing only.
475478 $user: the User object being authenticated against
@@ -569,9 +572,6 @@
570573 'SpecialContributionsBeforeMainOutput': Before the form on Special:Contributions
571574 $id: User identifier
572575
573 -'TitleLinkUpdatesAfterCompletion': after Linker->doUpdate() is called
574 -&$title: title of the updated page
575 -
576576 'TitleMoveComplete': after moving an article (title)
577577 $old: old title
578578 $nt: new title
Index: trunk/phase3/includes/LinksUpdate.php
@@ -64,6 +64,8 @@
6565 }
6666
6767 $this->mRecursive = $recursive;
 68+
 69+ wfRunHooks( 'LinksUpdateConstructed', array( &$this ) );
6870 }
6971
7072 /**
@@ -76,7 +78,6 @@
7779 } else {
7880 $this->doIncrementalUpdate();
7981 }
80 - wfRunHooks( 'TitleLinkUpdatesAfterCompletion', array( &$this->mTitle ) );
8182 }
8283
8384 function doIncrementalUpdate() {
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -617,74 +617,38 @@
618618 return true;
619619 }
620620
621 - public static function extraLinksUpdate( &$title ) {
 621+ public static function extraLinksUpdate( &$linkUpdate ) {
622622 $fname = 'FlaggedRevs::extraLinksUpdate';
623623 wfProfileIn( $fname );
624624
625 - if( !$title->isContentPage() )
 625+ if( !$linkUpdate->mTitle->isContentPage() )
626626 return true;
627627 # Check if this page has a stable version
628 - $sv = self::getOverridingPageRev( $title );
629 - if( !$sv )
 628+ $sv = self::getOverridingPageRev( $linkUpdate->mTitle );
 629+ if( !$sv )
630630 return true;
631631 # Retrieve the text
632632 $text = self::getFlaggedRevText( $sv->fr_rev_id );
633633 # Parse the revision
634634 $options = new ParserOptions;
635 - $poutput = self::parseStableText( $title, $text, $sv->fr_rev_id, $options );
636 -
 635+ $parserOutput = self::parseStableText( $linkUpdate->mTitle, $text, $sv->fr_rev_id, $options );
637636 # Might as well update the cache while we're at it
638 - $article = new Article( $title );
639 - FlaggedRevs::updatePageCache( $article, $poutput );
640 -
 637+ $article = new Article( $linkUpdate->mTitle );
 638+ FlaggedRevs::updatePageCache( $article, $parserOutput );
641639 # Update the links tables to include these
642640 # We want the UNION of links between the current
643641 # and stable version. Therefore, we only care about
644642 # links that are in the stable version and not the regular one.
645 - $u = new LinksUpdate( $article->mTitle, $poutput );
646 -
647 - # Page links
648 - $existing = $u->getExistingLinks();
649 - $u->incrTableUpdate( 'pagelinks', 'pl', array(),
650 - $u->getLinkInsertions( $existing ) );
651 -
652 - # Image links
653 - $existing = $u->getExistingImages();
654 - $u->incrTableUpdate( 'imagelinks', 'il', array(),
655 - $u->getImageInsertions( $existing ) );
656 -
657 - # Invalidate all image description pages which had links added
658 - $imageUpdates = array_diff_key( $u->mImages, $existing );
659 - $u->invalidateImageDescriptions( $imageUpdates );
660 -
661 - # External links
662 - $existing = $u->getExistingExternals();
663 - $u->incrTableUpdate( 'externallinks', 'el', array(),
664 - $u->getExternalInsertions( $existing ) );
665 -
666 - # Language links
667 - $existing = $u->getExistingInterlangs();
668 - $u->incrTableUpdate( 'langlinks', 'll', array(),
669 - $u->getInterlangInsertions( $existing ) );
670 -
671 - # Template links
672 - $existing = $u->getExistingTemplates();
673 - $u->incrTableUpdate( 'templatelinks', 'tl', array(),
674 - $u->getTemplateInsertions( $existing ) );
675 -
676 - # Category links
677 - $existing = $u->getExistingCategories();
678 - $u->incrTableUpdate( 'categorylinks', 'cl', array(),
679 - $u->getCategoryInsertions( $existing ) );
680 -
681 - # Invalidate all categories which were added, deleted or changed (set symmetric difference)
682 - $categoryUpdates = array_diff_assoc( $u->mCategories, $existing );
683 - $u->invalidateCategories( $categoryUpdates );
684 -
685 - # Refresh links of all pages including this page
686 - # This will be in a separate transaction
687 - if( $u->mRecursive ) {
688 - $u->queueRecursiveJobs();
 643+ $linkUpdate->mLinks += $parserOutput->getLinks();
 644+ $linkUpdate->mImages += $parserOutput->getImages();
 645+ $linkUpdate->mTemplates += $parserOutput->getTemplates();
 646+ $linkUpdate->mExternals += $parserOutput->getExternalLinks();
 647+ $linkUpdate->mCategories += $parserOutput->getCategories();
 648+ # Interlanguage links
 649+ $ill = $parserOutput->getLanguageLinks();
 650+ foreach( $ill as $link ) {
 651+ list( $key, $title ) = explode( ':', $link, 2 );
 652+ $linkUpdate->mInterlangs[$key] = $title;
689653 }
690654
691655 wfProfileOut( $fname );
@@ -1430,7 +1394,7 @@
14311395 // Autopromote Editors
14321396 $wgHooks['ArticleSaveComplete'][] = array($flaggedRevsModifier, 'autoPromoteUser');
14331397 // Adds table link references to include ones from the stable version
1434 -$wgHooks['TitleLinkUpdatesAfterCompletion'][] = array($flaggedRevsModifier, 'extraLinksUpdate');
 1398+$wgHooks['LinksUpdateConstructed'][] = array($flaggedRevsModifier, 'extraLinksUpdate');
14351399 // If a stable version is hidden, move to the next one if possible, and update things
14361400 $wgHooks['ArticleRevisionVisiblityUpdates'][] = array($flaggedRevsModifier, 'articleLinksUpdate');
14371401 // Update our table NS/Titles when things are moved
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php
@@ -29,18 +29,18 @@
3030 'revreview-quick-none' => '\'\'\'Current\'\'\'. No reviewed revisions.',
3131 'revreview-newest-basic' => 'The [{{fullurl:{{FULLPAGENAMEE}}|stable=1}} latest sighted revision]
3232 ([{{fullurl:Special:Stableversions|page={{FULLPAGENAMEE}}}} see all]) of this page was [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved]
33 - on <i>$2</i>. <br/> There {{plural:$3|is $3 revision|are $3 revisions}} ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} changes]) awaiting review.',
 33+ on <i>$2</i>. <br/> There {{plural:$3|is|are}} [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $3 {{plural:$3|revision|revisions}}] awaiting review.',
3434 'revreview-newest-quality' => 'The [{{fullurl:{{FULLPAGENAMEE}}|stable=1}} latest quality revision]
3535 ([{{fullurl:Special:Stableversions|page={{FULLPAGENAMEE}}}} see all]) of this page was [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved]
36 - on <i>$2</i>. <br/> There {{plural:$3|is $3 revision|are $3 revisions}} ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} changes]) awaiting review.',
 36+ on <i>$2</i>. <br/> There {{plural:$3|is|are}} [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $3 {{plural:$3|revision|revisions}}] awaiting review.',
3737 'revreview-basic' => 'This is the latest [[Help:Article validation|sighted]] revision of this page,
3838 [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>. The [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} current revision]
39 - is usually [{{fullurl:{{FULLPAGENAMEE}}|action=edit}} editable] and more up to date. There {{plural:$3|is $3 revision|are $3 revisions}}
40 - ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} changes]) awaiting review.',
 39+ is usually [{{fullurl:{{FULLPAGENAMEE}}|action=edit}} editable]. There {{plural:$3|is|are}} [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}}
 40+ $3 {{plural:$3|revision|revisions}}] awaiting review.',
4141 'revreview-quality' => 'This is the latest [[Help:Article validation|quality]] revision of this page,
4242 [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved] on <i>$2</i>. The [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} current revision]
43 - is usually [{{fullurl:{{FULLPAGENAMEE}}|action=edit}} editable] and more up to date. There {{plural:$3|is $3 revision|are $3 revisions}}
44 - ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} changes]) awaiting review.',
 43+ is usually [{{fullurl:{{FULLPAGENAMEE}}|action=edit}} editable]. There {{plural:$3|is|are}}
 44+ [{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} $3 {{plural:$3|revision|revisions}}] awaiting review.',
4545 'revreview-static' => 'This is a [[Help:Article validation|reviewed]] revision of \'\'\'[[:$3|this page]]\'\'\',
4646 [{{fullurl:Special:Log/review|page=$1}} approved] on <i>$2</i>. The [{{fullurl:$3|stable=0}} current revision]
4747 is usually editable and more up to date.',
@@ -196,7 +196,7 @@
197197
198198 'revreview-newest-quality' => 'Die [{{fullurl:{{FULLPAGENAMEE}}|stable=1}} letzte geprüfte Version]
199199 ([{{fullurl:Special:Stableversions|page={{FULLPAGENAMEE}}}} siehe alle]) diese Seite wurde am <i>$2</i> [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} freigegeben]<br/>
200 - There {{plural:$3|is $3 revision|are $3 revisions}} ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} changes]) awaiting review.',
 200+ {{plural:$3|1 Version steht|$3 Versionen stehen}} ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=cur}} Änderungen]) noch zur Prüfung an.',
201201
202202 'revreview-basic' => 'Dies ist die letzte [[Help:Gesichtete Versionen|gesichtete]] Version dieser Seite,
203203 [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} freigegeben] am <i>$2</i>. Die [{{fullurl:{{FULLPAGENAMEE}}|stable=0}} derzeitige Version]

Follow-up revisions

RevisionCommit summaryAuthorDate
r24276Merged revisions 24213-24275 via svnmerge from...david20:20, 19 July 2007

Status & tagging log