Revert r36076, r36109, r36110 -- just doesn't work right. Sometimes removes blocks...
[lhc/web/wiklou.git] / includes / RefreshLinksJob.php
1 <?php
2
3 /**
4 * Background job to update links for a given title.
5 *
6 * @ingroup JobQueue
7 */
8 class RefreshLinksJob extends Job {
9
10 function __construct( $title, $params = '', $id = 0 ) {
11 parent::__construct( 'refreshLinks', $title, $params, $id );
12 }
13
14 /**
15 * Run a refreshLinks job
16 * @return boolean success
17 */
18 function run() {
19 global $wgParser;
20 wfProfileIn( __METHOD__ );
21
22 $linkCache = LinkCache::singleton();
23 $linkCache->clear();
24
25 if ( is_null( $this->title ) ) {
26 $this->error = "refreshLinks: Invalid title";
27 wfProfileOut( __METHOD__ );
28 return false;
29 }
30
31 $revision = Revision::newFromTitle( $this->title );
32 if ( !$revision ) {
33 $this->error = 'refreshLinks: Article not found "' . $this->title->getPrefixedDBkey() . '"';
34 wfProfileOut( __METHOD__ );
35 return false;
36 }
37
38 wfProfileIn( __METHOD__.'-parse' );
39 $user = new User();
40 $options = new ParserOptions( $user );
41 $options->setInterfaceMessage( true );
42 $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options, true, true, $revision->getId() );
43 wfProfileOut( __METHOD__.'-parse' );
44 wfProfileIn( __METHOD__.'-update' );
45 $update = new LinksUpdate( $this->title, $parserOutput, false );
46 $update->doUpdate();
47 wfProfileOut( __METHOD__.'-update' );
48 wfProfileOut( __METHOD__ );
49 return true;
50 }
51 }