Sbisson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/234089

Change subject: Allow converting entire LQT namespaces
......................................................................

Allow converting entire LQT namespaces

* Renamed ConvertLqtPagesWithProperty to ConvertAllLqtPages

* Removed the unused startId and startId arguments

* When $wgLqtTalkPages, consider all pages in all
  talk namespaces for conversion

* Adds #useliquidthreads:0 after conversion to ensure
  a page is not LQT anymore.

Bug: T109931
Change-Id: If23f737a60e8a8b7e05d80728fbe8bbe5679392f
---
M includes/Import/LiquidThreadsApi/ConversionStrategy.php
M includes/Import/LiquidThreadsApi/Objects.php
M includes/Import/LiquidThreadsApi/Source.php
R maintenance/convertAllLqtPages.php
4 files changed, 38 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/89/234089/1

diff --git a/includes/Import/LiquidThreadsApi/ConversionStrategy.php 
b/includes/Import/LiquidThreadsApi/ConversionStrategy.php
index fb06563..0b2a5de 100644
--- a/includes/Import/LiquidThreadsApi/ConversionStrategy.php
+++ b/includes/Import/LiquidThreadsApi/ConversionStrategy.php
@@ -60,6 +60,8 @@
 
        const LQT_ENABLE_MAGIC_WORD_REGEX = 
'/{{\s*#useliquidthreads:\s*0*1\s*}}/i';
 
+       const LQT_DISABLE_MAGIC_WORD = '{{#useliquidthreads:0}}';
+
        public function __construct(
                DatabaseBase $dbw,
                ImportSourceStore $sourceStore,
@@ -117,10 +119,8 @@
        }
 
        /**
-        * Creates a new revision that strips the LQT magic word (if any) and 
injects a
-        * template about the move. With the magic word stripped, these pages 
will no
-        * longer contain the use-liquid-threads page property.  Unless LQT 
applies for an
-        * additional reason ($wgLqtTalkPages, $wgLqtNamespaces, $wgLqtPages), 
they will
+        * Creates a new revision that ensures the LQT magic word is there and 
turning LQT off.
+        * It also adds a template about the move.
         * effectively no longer be LQT pages.
         *
         * @param WikitextContent $content
@@ -138,6 +138,8 @@
                        '',
                        $content->getNativeData()
                );
+               $newWikitext = self::LQT_DISABLE_MAGIC_WORD . "\n\n" . 
$newWikitext;
+
                $template = wfMessage( 
'flow-importer-lqt-converted-archive-template' )->inContentLanguage()->plain();
                $newWikitext = "{{{$template}|$arguments}}\n\n" . $newWikitext;
 
diff --git a/includes/Import/LiquidThreadsApi/Objects.php 
b/includes/Import/LiquidThreadsApi/Objects.php
index b3b7848..f43cb1e 100644
--- a/includes/Import/LiquidThreadsApi/Objects.php
+++ b/includes/Import/LiquidThreadsApi/Objects.php
@@ -531,6 +531,7 @@
                        '',
                        $wikitextForLastRevision
                );
+               $newWikitext = ConversionStrategy::LQT_DISABLE_MAGIC_WORD . 
"\n\n" . $newWikitext;
                $templateName = wfMessage( 
'flow-importer-lqt-converted-template' )->inContentLanguage()->plain();
                $arguments = implode( '|', array(
                        'archive=' . $archiveTitle->getPrefixedText(),
diff --git a/includes/Import/LiquidThreadsApi/Source.php 
b/includes/Import/LiquidThreadsApi/Source.php
index 004b0d7..53e7b40 100644
--- a/includes/Import/LiquidThreadsApi/Source.php
+++ b/includes/Import/LiquidThreadsApi/Source.php
@@ -58,6 +58,7 @@
        /**
         * @param ApiBackend $apiBackend
         * @param string $pageName
+        * @param User $scriptUser
         */
        public function __construct( ApiBackend $apiBackend, $pageName, User 
$scriptUser ) {
                $this->api = $apiBackend;
diff --git a/maintenance/convertLqtPagesWithProp.php 
b/maintenance/convertAllLqtPages.php
similarity index 66%
rename from maintenance/convertLqtPagesWithProp.php
rename to maintenance/convertAllLqtPages.php
index 89682f9..2e75b70 100644
--- a/maintenance/convertLqtPagesWithProp.php
+++ b/maintenance/convertAllLqtPages.php
@@ -4,6 +4,7 @@
 use Flow\Import\FileImportSourceStore;
 use Flow\Import\LiquidThreadsApi\ConversionStrategy;
 use Flow\Import\LiquidThreadsApi\LocalApiBackend;
+use Flow\Utils\NamespaceIterator;
 use Flow\Utils\PagesWithPropertyIterator;
 use Psr\Log\LogLevel;
 
@@ -16,14 +17,12 @@
  * option this process is idempotent.It may be run many times and will only 
import
  * one copy of each item.
  */
-class ConvertLqt extends Maintenance {
+class ConvertAllLqtPages extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Converts LiquidThreads data to Flow 
data";
                $this->addOption( 'logfile', 'File to read and store 
associations between imported items and their sources. This is required for the 
import to be idempotent.', true, true );
                $this->addOption( 'debug', 'Include debug information with 
progress report' );
-               $this->addOption( 'startId', 'Page id to start importing at 
(inclusive)' );
-               $this->addOption( 'stopId', 'Page id to stop importing at 
(exclusive)' );
        }
 
        public function execute() {
@@ -55,15 +54,38 @@
                        $strategy
                );
 
-               $startId = $this->getOption( 'startId' );
-               $stopId = $this->getOption( 'stopId' );
+               $titles = $this->buildIterator( $logger, $dbw );
 
-               $logger->info( "Starting full wiki LQT conversion of all pages 
with use-liquid-threads property" );
-               $titles = new PagesWithPropertyIterator( $dbw, 
'use-liquid-threads', $startId, $stopId );
+               $logger->info( "Starting full wiki LQT conversion of all 
LiquidThreads pages" );
                $converter->convertAll( $titles );
                $logger->info( "Finished conversion" );
        }
+
+       /**
+        * @param $logger
+        * @param $dbw
+        * @return AppendIterator
+        */
+       private function buildIterator( $logger, $dbw ) {
+               global $wgLqtTalkPages;
+
+               $iterator = new AppendIterator();
+
+               $logger->info( "Considering for conversion: pages with the 
'use-liquid-threads' property" );
+               $withProperty = new PagesWithPropertyIterator( $dbw, 
'use-liquid-threads' );
+               $iterator->append( $withProperty->getIterator() );
+
+               if ( $wgLqtTalkPages ) {
+                       foreach ( MWNamespace::getTalkNamespaces() as $ns ) {
+                               $logger->info( "Considering for conversion: 
pages in namespace $ns" );
+                               $it = new NamespaceIterator( $dbw, $ns );
+                               $iterator->append( $it->getIterator() );
+                       }
+               }
+
+               return $iterator;
+       }
 }
 
-$maintClass = "ConvertLqt";
+$maintClass = "ConvertAllLqtPages";
 require_once ( RUN_MAINTENANCE_IF_MAIN );

-- 
To view, visit https://gerrit.wikimedia.org/r/234089
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If23f737a60e8a8b7e05d80728fbe8bbe5679392f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to