MediaWiki  1.27.2
RefreshLinksPartitionTest.php
Go to the documentation of this file.
1 <?php
2 
9  public function __construct( $name = null, array $data = [], $dataName = '' ) {
10  parent::__construct( $name, $data, $dataName );
11 
12  $this->tablesUsed[] = 'page';
13  $this->tablesUsed[] = 'revision';
14  $this->tablesUsed[] = 'pagelinks';
15  }
16 
20  public function testRefreshLinks( $ns, $dbKey, $pages ) {
21  $title = Title::makeTitle( $ns, $dbKey );
22 
23  foreach ( $pages as $page ) {
24  list( $bns, $bdbkey ) = $page;
25  $bpage = WikiPage::factory( Title::makeTitle( $bns, $bdbkey ) );
26  $content = ContentHandler::makeContent( "[[{$title->getPrefixedText()}]]", $bpage->getTitle() );
27  $bpage->doEditContent( $content, "test" );
28  }
29 
30  $title->getBacklinkCache()->clear();
31  $this->assertEquals(
32  20,
33  $title->getBacklinkCache()->getNumLinks( 'pagelinks' ),
34  'Correct number of backlinks'
35  );
36 
37  $job = new RefreshLinksJob( $title, [ 'recursive' => true, 'table' => 'pagelinks' ]
38  + Job::newRootJobParams( "refreshlinks:pagelinks:{$title->getPrefixedText()}" ) );
39  $extraParams = $job->getRootJobParams();
40  $jobs = BacklinkJobUtils::partitionBacklinkJob( $job, 9, 1, [ 'params' => $extraParams ] );
41 
42  $this->assertEquals( 10, count( $jobs ), 'Correct number of sub-jobs' );
43  $this->assertEquals( $pages[0], current( $jobs[0]->params['pages'] ),
44  'First job is leaf job with proper title' );
45  $this->assertEquals( $pages[8], current( $jobs[8]->params['pages'] ),
46  'Last leaf job is leaf job with proper title' );
47  $this->assertEquals( true, isset( $jobs[9]->params['recursive'] ),
48  'Last job is recursive sub-job' );
49  $this->assertEquals( true, $jobs[9]->params['recursive'],
50  'Last job is recursive sub-job' );
51  $this->assertEquals( true, is_array( $jobs[9]->params['range'] ),
52  'Last job is recursive sub-job' );
53  $this->assertEquals( $title->getPrefixedText(), $jobs[0]->getTitle()->getPrefixedText(),
54  'Base job title retainend in leaf job' );
55  $this->assertEquals( $title->getPrefixedText(), $jobs[9]->getTitle()->getPrefixedText(),
56  'Base job title retainend recursive sub-job' );
57  $this->assertEquals( $extraParams['rootJobSignature'], $jobs[0]->params['rootJobSignature'],
58  'Leaf job has root params' );
59  $this->assertEquals( $extraParams['rootJobSignature'], $jobs[9]->params['rootJobSignature'],
60  'Recursive sub-job has root params' );
61 
63  $jobs[9],
64  9,
65  1,
66  [ 'params' => $extraParams ]
67  );
68 
69  $this->assertEquals( 10, count( $jobs2 ), 'Correct number of sub-jobs' );
70  $this->assertEquals( $pages[9], current( $jobs2[0]->params['pages'] ),
71  'First job is leaf job with proper title' );
72  $this->assertEquals( $pages[17], current( $jobs2[8]->params['pages'] ),
73  'Last leaf job is leaf job with proper title' );
74  $this->assertEquals( true, isset( $jobs2[9]->params['recursive'] ),
75  'Last job is recursive sub-job' );
76  $this->assertEquals( true, $jobs2[9]->params['recursive'],
77  'Last job is recursive sub-job' );
78  $this->assertEquals( true, is_array( $jobs2[9]->params['range'] ),
79  'Last job is recursive sub-job' );
80  $this->assertEquals( $extraParams['rootJobSignature'], $jobs2[0]->params['rootJobSignature'],
81  'Leaf job has root params' );
82  $this->assertEquals( $extraParams['rootJobSignature'], $jobs2[9]->params['rootJobSignature'],
83  'Recursive sub-job has root params' );
84 
86  $jobs2[9],
87  9,
88  1,
89  [ 'params' => $extraParams ]
90  );
91 
92  $this->assertEquals( 2, count( $jobs3 ), 'Correct number of sub-jobs' );
93  $this->assertEquals( $pages[18], current( $jobs3[0]->params['pages'] ),
94  'First job is leaf job with proper title' );
95  $this->assertEquals( $extraParams['rootJobSignature'], $jobs3[0]->params['rootJobSignature'],
96  'Leaf job has root params' );
97  $this->assertEquals( $pages[19], current( $jobs3[1]->params['pages'] ),
98  'Last job is leaf job with proper title' );
99  $this->assertEquals( $extraParams['rootJobSignature'], $jobs3[1]->params['rootJobSignature'],
100  'Last leaf job has root params' );
101  }
102 
103  public static function provider_backlinks() {
104  $pages = [];
105  for ( $i = 0; $i < 20; ++$i ) {
106  $pages[] = [ 0, "Page-$i" ];
107  }
108  return [
109  [ 10, 'Bang', $pages ]
110  ];
111  }
112 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:99
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
the array() calling protocol came about after MediaWiki 1.4rc1.
static newRootJobParams($key)
Get "root job" parameters for a task.
Definition: Job.php:261
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
static makeContent($text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Job to update link tables for pages.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
__construct($name=null, array $data=[], $dataName= '')
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
Definition: hooks.txt:1004
if(count($args)< 1) $job
static partitionBacklinkJob(Job $job, $bSize, $cSize, $opts=[])
Break down $job into approximately ($bSize/$cSize) leaf jobs and a single partition job that covers t...
JobQueue medium Database.
testRefreshLinks($ns, $dbKey, $pages)
provider_backlinks
static & makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:524
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2338
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310