Smalyshev has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/352718 )
Change subject: Allow to explicitly index archive when given option.
......................................................................
Allow to explicitly index archive when given option.
Now it should work this way:
--deletes indexes deletes and if enabled by option, indexes archive too.
--archive indexes only archive regardless of the option.
This allows to pre-index deletes for a wiki before enabling it in config
(which requires mapping already being there).
Change-Id: I6bf8edc2fc91f8af03d2dfdfbe3dbdee73c03d4e
---
M includes/Updater.php
M maintenance/forceSearchIndex.php
2 files changed, 13 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/18/352718/1
diff --git a/includes/Updater.php b/includes/Updater.php
index 8758245..ba8ba34 100644
--- a/includes/Updater.php
+++ b/includes/Updater.php
@@ -258,10 +258,11 @@
/**
* Add documents to archive index.
* @param array $archived
+ * @param bool $forceIndex If true, index to archive regardless of
config.
* @return bool
*/
- public function archivePages( $archived ) {
- if ( !$this->searchConfig->getElement(
'CirrusSearchIndexDeletes' ) ) {
+ public function archivePages( $archived, $forceIndex = false ) {
+ if ( !$this->searchConfig->getElement(
'CirrusSearchIndexDeletes' ) && !$forceIndex ) {
// Disabled by config - don't do anything
return true;
}
diff --git a/maintenance/forceSearchIndex.php b/maintenance/forceSearchIndex.php
index d53404f..057b221 100644
--- a/maintenance/forceSearchIndex.php
+++ b/maintenance/forceSearchIndex.php
@@ -80,7 +80,7 @@
$this->addOption( 'toId', 'Stop indexing at a specific page_id.
Not useful with --deletes or --from or --to.', false, true );
$this->addOption( 'ids', 'List of page ids (comma separated) to
reindex. Not allowed with deletes/from/to/fromId/toId/limit.', false, true );
$this->addOption( 'deletes', 'If this is set then just index
deletes, not updates or creates.', false );
- $this->addOption( 'archiveOnly', 'Don\'t delete pages, only
index them into the archive. Only useful with --deletes', false, false );
+ $this->addOption( 'archive', 'Don\'t delete pages, only index
them into the archive.', false, false );
$this->addOption( 'limit', 'Maximum number of pages to process
before exiting the script. Default to unlimited.', false, true );
$this->addOption( 'buildChunks', 'Instead of running the script
spit out commands that can be farmed out to ' .
'different processes or machines to rebuild the index.
Works with fromId and toId, not from and to. ' .
@@ -131,6 +131,10 @@
$this->toId = $this->getOption( 'toId' );
$this->indexUpdates = !$this->getOption( 'deletes', false );
$this->archiveOnly = (bool) $this->getOption( 'archiveOnly',
false );
+ if ( $this->archiveOnly ) {
+ // If we're indexing only for archive, this implies
deletes
+ $this->indexUpdates = false;
+ }
$this->limit = $this->getOption( 'limit' );
$buildChunks = $this->getOption( 'buildChunks' );
if ( $buildChunks !== null ) {
@@ -144,7 +148,8 @@
$updateFlags = $this->buildUpdateFlags();
if ( !$this->getOption( 'batch-size' ) &&
- ( $this->getOption( 'queue' ) || $this->getOption(
'deletes' ) )
+ ( $this->getOption( 'queue' ) || $this->getOption(
'deletes' ) ||
+ $this->getOption( 'archive' ) )
) {
$this->setBatchSize( 100 );
}
@@ -192,7 +197,7 @@
} else {
$size = count( $batch['titlesToDelete'] );
$updater = $this->createUpdater();
- $updater->archivePages( $batch['archive'] );
+ $updater->archivePages( $batch['archive'],
$this->archiveOnly );
if ( !$this->archiveOnly ) {
$updater->deletePages(
$batch['titlesToDelete'], $batch['docIdsToDelete'] );
}
@@ -214,7 +219,8 @@
private function buildPageIdBatches() {
if ( $this->getOption( 'deletes' ) || $this->hasOption( 'limit'
)
|| $this->hasOption( 'from' ) || $this->hasOption( 'to'
)
- || $this->hasOption( 'fromId' ) || $this->hasOption(
'toId' )
+ || $this->hasOption( 'fromId' ) || $this->hasOption(
'toId' ) ||
+ $this->getOption( 'archive' )
) {
$this->error( '--ids cannot be used with
deletes/from/to/fromId/toId/limit', 1 );
}
--
To view, visit https://gerrit.wikimedia.org/r/352718
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6bf8edc2fc91f8af03d2dfdfbe3dbdee73c03d4e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits