Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/139768
Change subject: Add simple script to "touch" pages
......................................................................
Add simple script to "touch" pages
Provides different options and levels of updating pages,
including:
* basic invalidation with Title::invalidateCache()
* null-edits
* re-parsing later?
* re-applying data updates
The script takes a comma separated list of pages ids as
it's input.
Bug: 64600
Change-Id: I5ccdd5bdd5881e64375c5a1ca0e03811a934d285
---
A repo/maintenance/touchPage.php
1 file changed, 80 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/68/139768/1
diff --git a/repo/maintenance/touchPage.php b/repo/maintenance/touchPage.php
new file mode 100644
index 0000000..20381e5
--- /dev/null
+++ b/repo/maintenance/touchPage.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace Wikibase;
+use Maintenance;
+use Revision;
+use Title;
+use User;
+use WikiPage;
+
+$IP = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) :
__DIR__ . '/../../../..';
+
+// Require base maintenance class
+require_once( "$IP/maintenance/Maintenance.php" );
+
+class TouchPage extends Maintenance {
+
+ public function __construct() {
+ parent::__construct();
+ $this->addOption( 'invalidate', 'Invalidate the parser cache' );
+ $this->addOption( 'nulledit', 'Re-parse the page by a null
edit' );
+ //$this->addOption( 'parselater', 'Queue RefreshLinksJob2 jobs
for the page' );
+ $this->addOption( 'dataupdates', 'Apply data updates' );
+ $this->addArg( 'pageids', 'Page Ids to update, separated by
commas' );
+ }
+
+ public function execute() {
+ $ids = explode( ',', $this->getArg() );
+ $titles = Title::newFromIDs( $ids );
+ foreach ( $titles as $title ) {
+ if ( $this->hasOption( 'invalidate' ) ) {
+ $this->doInvalidate( $title );
+ }
+ if ( $this->hasOption( 'nulledit' ) ) {
+ $this->doNullEdit( $title );
+ }
+ if ( $this->hasOption( 'parselater' ) ) {
+ $this->doParseLater( $title );
+ }
+ if ( $this->hasOption( 'dataupdates' ) ) {
+ $this->doDataUpdates( $title );
+ }
+ }
+ }
+
+ private function doInvalidate( Title $title ) {
+ $title->invalidateCache();
+ $this->output( "Invalidated cache of
{$title->getPrefixedText()}\n" );
+ }
+
+ private function doNullEdit( Title $title ) {
+ $rev = Revision::newFromTitle( $title );
+ $content = $rev->getContent();
+ $page = WikiPage::factory( $title );
+ $page->doEditContent(
+ $content,
+ 'Null-edit',
+ EDIT_SUPPRESS_RC | EDIT_UPDATE,
+ $rev->getId(),
+ User::newFromName( 'MediaWiki default' )
+ );
+ $this->output( "Null-edited of {$title->getPrefixedText()}\n" );
+ }
+
+ private function doParseLater( Title $title ) {
+ // not sure what to do here.
+ //$this->output( "Queued jobs for
{$title->getPrefixedText()}\n" );
+ }
+
+ private function doDataUpdates( Title $title ) {
+ $rev = Revision::newFromTitle( $title );
+ $content = $rev->getContent();
+ foreach ( $content->getSecondaryDataUpdates( $title ) as $upd )
{
+ $upd->doUpdate();
+ }
+ $this->output( "Ran data updates for
{$title->getPrefixedText()}\n" );
+ }
+}
+
+$maintClass = 'Wikibase\TouchPage';
+require_once( RUN_MAINTENANCE_IF_MAIN );
--
To view, visit https://gerrit.wikimedia.org/r/139768
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ccdd5bdd5881e64375c5a1ca0e03811a934d285
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits