Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93980
Change subject: Add a RefreshLinks job when a template is deleted
......................................................................
Add a RefreshLinks job when a template is deleted
When a template is deleted, all pages transcluding it need to be
reparsed so that entries for transcluding pages in the various links
tables due to the transcluded content are properly removed.
Bug: 5382
Change-Id: I838b546caa3f5887e6bd312017c1fa71d3c3463a
---
M includes/WikiPage.php
M tests/phpunit/includes/TemplateCategoriesTest.php
2 files changed, 54 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/80/93980/1
diff --git a/includes/WikiPage.php b/includes/WikiPage.php
index 6d2d80c..576979c 100644
--- a/includes/WikiPage.php
+++ b/includes/WikiPage.php
@@ -2747,6 +2747,9 @@
$updates = $this->getDeletionUpdates( $content );
DataUpdate::runUpdates( $updates );
+ // Reparse any pages transcluding this page
+ LinksUpdate::queueRecursiveJobsForTable( $this->mTitle,
'templatelinks' );
+
// Clear caches
WikiPage::onArticleDelete( $this->mTitle );
diff --git a/tests/phpunit/includes/TemplateCategoriesTest.php
b/tests/phpunit/includes/TemplateCategoriesTest.php
index fb63a56..b0d1726 100644
--- a/tests/phpunit/includes/TemplateCategoriesTest.php
+++ b/tests/phpunit/includes/TemplateCategoriesTest.php
@@ -11,11 +11,11 @@
* @covers Title::getParentCategories
*/
public function testTemplateCategories() {
+ $user = new User();
+ $user->mRights = array( 'createpage', 'edit', 'purge', 'delete'
);
+
$title = Title::newFromText( "Categorized from template" );
$page = WikiPage::factory( $title );
- $user = new User();
- $user->mRights = array( 'createpage', 'edit', 'purge' );
-
$page->doEditContent(
new WikitextContent( '{{Categorising template}}' ),
'Create a page with a template',
@@ -25,12 +25,13 @@
);
$this->assertEquals(
- array()
- , $title->getParentCategories()
+ array(),
+ $title->getParentCategories(),
+ 'Verify that the category doesn\'t contain the page
before the template is created'
);
+ // Create template
$template = WikiPage::factory( Title::newFromText(
'Template:Categorising template' ) );
-
$template->doEditContent(
new WikitextContent( '[[Category:Solved bugs]]' ),
'Add a category through a template',
@@ -45,9 +46,51 @@
$jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null
);
$jobs->execute();
+ // Make sure page is in the category
$this->assertEquals(
- array( 'Category:Solved_bugs' =>
$title->getPrefixedText() )
- , $title->getParentCategories()
+ array( 'Category:Solved_bugs' =>
$title->getPrefixedText() ),
+ $title->getParentCategories(),
+ 'Verify that the page is in the category after the
template is created'
);
+
+ // Edit the template
+ $template->doEditContent(
+ new WikitextContent( '[[Category:Solved bugs 2]]' ),
+ 'Change the category added by the template',
+ 0,
+ false,
+ $user
+ );
+
+ // Run the job queue
+ JobQueueGroup::destroySingletons();
+ $jobs = new RunJobs;
+ $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null
);
+ $jobs->execute();
+
+ // Make sure page is in the right category
+ $this->assertEquals(
+ array( 'Category:Solved_bugs_2' =>
$title->getPrefixedText() ),
+ $title->getParentCategories(),
+ 'Verify that the page is in the right category after
the template is edited'
+ );
+
+ // Now delete the template
+ $error = '';
+ $template->doDeleteArticleReal( 'Delete the template', false,
0, true, $error, $user );
+
+ // Run the job queue
+ JobQueueGroup::destroySingletons();
+ $jobs = new RunJobs;
+ $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null
);
+ $jobs->execute();
+
+ // Make sure the page is no longer in the category
+ $this->assertEquals(
+ array(),
+ $title->getParentCategories(),
+ 'Verify that the page is no longer in the category
after template deletion'
+ );
+
}
}
--
To view, visit https://gerrit.wikimedia.org/r/93980
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I838b546caa3f5887e6bd312017c1fa71d3c3463a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits