jenkins-bot has submitted this change and it was merged.

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/Source.php
R maintenance/convertAllLqtPages.php
M tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php
4 files changed, 41 insertions(+), 15 deletions(-)

Approvals:
  Mattflaschen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Import/LiquidThreadsApi/ConversionStrategy.php 
b/includes/Import/LiquidThreadsApi/ConversionStrategy.php
index fb06563..0a6e071 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,
@@ -89,7 +91,6 @@
        }
 
        public function isConversionFinished( Title $title, Title $movedFrom = 
null ) {
-               // After successful conversion we strip the LQT magic word
                if ( LqtDispatch::isLqtPage( $title ) ) {
                        return false;
                } else {
@@ -117,10 +118,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 +137,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/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 );
diff --git a/tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php 
b/tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php
index 0823c52..2e2b1ee 100644
--- a/tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php
+++ b/tests/phpunit/Import/LiquidThreadsApi/ConversionStrategyTest.php
@@ -85,14 +85,14 @@
                        array(
                                'Blank input page',
                                // expect
-                               "{{Archive for converted LQT 
page|from=Talk:Blue birds|date=$date}}\n\n",
+                               "{{Archive for converted LQT 
page|from=Talk:Blue birds|date=$date}}\n\n{{#useliquidthreads:0}}\n\n",
                                // input content
                                '',
                        ),
                        array(
                                'Page containing lqt magic word',
                                // expect
-                               "{{Archive for converted LQT 
page|from=Talk:Blue birds|date=$date}}\n\n",
+                               "{{Archive for converted LQT 
page|from=Talk:Blue birds|date=$date}}\n\n{{#useliquidthreads:0}}\n\n",
                                // input content
                                '{{#useliquidthreads:1}}',
                        ),
@@ -103,6 +103,8 @@
                                <<<EOD
 {{Archive for converted LQT page|from=Talk:Blue birds|date=$date}}
 
+{{#useliquidthreads:0}}
+
 Four score and seven years ago our fathers brought forth
 on this continent, a new nation, conceived in Liberty, and
 dedicated to the proposition that all men are created equal.

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If23f737a60e8a8b7e05d80728fbe8bbe5679392f
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to