r89130 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89129‎ | r89130 | r89131 >
Date:19:24, 29 May 2011
Author:aaron
Status:ok
Tags:
Comment:
More missing changes from r89124...wtf
Modified paths:
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/cachePendingRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/maintenance/cachePendingRevs.php
@@ -39,7 +39,7 @@
4040 $rev = new Revision( $row );
4141 // Trigger cache regeneration
4242 $start = microtime( true );
43 - RevisionReviewForm::getRevIncludes( $article, $rev, $wgUser, 'regen' );
 43+ FRInclusionCache::getRevIncludes( $article, $rev, $wgUser, 'regen' );
4444 $elapsed = intval( ( microtime( true ) - $start ) * 1000 );
4545 $this->cachePendingRevsLog(
4646 $title->getPrefixedDBkey() . " rev:" . $rev->getId() . " {$elapsed}ms" );
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -575,91 +575,4 @@
576576 }
577577 return array( $templateIds, $fileSHA1Keys );
578578 }
579 -
580 - /**
581 - * Get template and image versions from parsing a revision
582 - * @param Article $article
583 - * @param Revision $rev
584 - * @param User $user
585 - * @param string $regen use 'regen' to force regeneration
586 - * @return array( templateIds, fileSHA1Keys )
587 - * templateIds like ParserOutput->mTemplateIds
588 - * fileSHA1Keys like ParserOutput->mImageTimeKeys
589 - */
590 - public static function getRevIncludes(
591 - Article $article, Revision $rev, User $user, $regen = ''
592 - ) {
593 - global $wgParser, $wgMemc;
594 - wfProfileIn( __METHOD__ );
595 - $versions = false;
596 - $hash = md5( $article->getTitle()->getPrefixedDBkey() );
597 - $key = wfMemcKey( 'flaggedrevs', 'revIncludes', $rev->getId(), $hash );
598 - if ( $regen !== 'regen' ) { // check cache
599 - $versions = FlaggedRevs::getMemcValue( $wgMemc->get( $key ), $article, 'allowStale' );
600 - }
601 - if ( !is_array( $versions ) ) { // cache miss
602 - $pOut = false;
603 - if ( $rev->isCurrent() ) {
604 - $parserCache = ParserCache::singleton();
605 - # Try current version parser cache (as anon)...
606 - $pOut = $parserCache->get( $article, $article->makeParserOptions( $user ) );
607 - if ( $pOut == false && $rev->getUser() ) { // try the user who saved the change
608 - $author = User::newFromId( $rev->getUser() );
609 - $pOut = $parserCache->get( $article, $article->makeParserOptions( $author ) );
610 - }
611 - }
612 - if ( $pOut == false ) {
613 - $title = $article->getTitle();
614 - $pOpts = ParserOptions::newFromUser( $user ); // Note: tidy off
615 - # Disable slow crap that doesn't matter for getting templates/files...
616 - $parser = clone $wgParser;
617 - $parser->clearTagHook( 'ref' );
618 - $parser->clearTagHook( 'references' );
619 - $pOut = $parser->parse(
620 - $rev->getText(), $title, $pOpts, true, true, $rev->getId() );
621 - }
622 - # Get the template/file versions used...
623 - $versions = array( $pOut->getTemplateIds(), $pOut->getImageTimeKeys() );
624 - # Save to cache...
625 - $data = FlaggedRevs::makeMemcObj( $versions );
626 - $wgMemc->set( $key, $data, 24*3600 ); // inclusions may be dynamic
627 - } else {
628 - # Do a link batch query for page_latest...
629 - $lb = new LinkBatch();
630 - foreach ( $versions as $ns => $tmps ) {
631 - foreach ( $tmps as $dbKey => $revIdDraft ) {
632 - $lb->add( $ns, $dbKey );
633 - }
634 - }
635 - $lb->execute();
636 - # Update array with the current page_latest values.
637 - # This kludge is there since $newTemplates (thus $revIdDraft) is cached.
638 - foreach ( $versions as $ns => $tmps ) {
639 - foreach ( $tmps as $dbKey => &$revIdDraft ) {
640 - $title = new Title( $ns, $dbKey );
641 - $revIdDraft = (int)$title->getLatestRevID();
642 - }
643 - }
644 - }
645 - wfProfileOut( __METHOD__ );
646 - return $versions;
647 - }
648 -
649 - /**
650 - * Set template and image versions from parsing a revision
651 - * @param Title $title
652 - * @param int $revId
653 - * @param ParserOutput $rev
654 - * @return void
655 - */
656 - public static function setRevIncludes( Title $title, $revId, ParserOutput $pOut ) {
657 - global $wgMemc;
658 - $hash = md5( $title->getPrefixedDBkey() );
659 - $key = wfMemcKey( 'flaggedrevs', 'revIncludes', $revId, $hash );
660 - # Get the template/file versions used...
661 - $versions = array( $pOut->getTemplateIds(), $pOut->getImageTimeKeys() );
662 - # Save to cache...
663 - $data = FlaggedRevs::makeMemcObj( $versions );
664 - $wgMemc->set( $key, $data, 24*3600 ); // inclusions may be dynamic
665 - }
666579 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89124* Moved *RevIncludes functions to new FRInclusionCache class...aaron18:44, 29 May 2011

Status & tagging log