]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/RefreshLinksJob.php
MediaWiki 1.11.0-scripts
[autoinstallsdev/mediawiki.git] / includes / RefreshLinksJob.php
1 <?php
2
3 /**
4  * Background job to update links for a given title.
5  */
6 class RefreshLinksJob extends Job {
7
8         function __construct( $title, $params = '', $id = 0 ) {
9                 parent::__construct( 'refreshLinks', $title, $params, $id );
10         }
11
12         /**
13          * Run a refreshLinks job
14          * @return boolean success
15          */
16         function run() {
17                 global $wgParser;
18                 wfProfileIn( __METHOD__ );
19
20                 $linkCache =& LinkCache::singleton();
21                 $linkCache->clear();
22
23                 if ( is_null( $this->title ) ) {
24                         $this->error = "refreshLinks: Invalid title";
25                         wfProfileOut( __METHOD__ );
26                         return false;
27                 }
28
29                 $revision = Revision::newFromTitle( $this->title );
30                 if ( !$revision ) {
31                         $this->error = 'refreshLinks: Article not found "' . $this->title->getPrefixedDBkey() . '"';
32                         wfProfileOut( __METHOD__ );
33                         return false;
34                 }
35
36                 wfProfileIn( __METHOD__.'-parse' );
37                 $options = new ParserOptions;
38                 $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() );
39                 wfProfileOut( __METHOD__.'-parse' );
40                 wfProfileIn( __METHOD__.'-update' );
41                 $update = new LinksUpdate( $this->title, $parserOutput, false );
42                 $update->doUpdate();
43                 wfProfileOut( __METHOD__.'-update' );
44                 wfProfileOut( __METHOD__ );
45                 return true;
46         }
47 }
48