diff --git a/module/VuFindConsole/config/module.config.php b/module/VuFindConsole/config/module.config.php index a1099a66534f9a3bdfe3170d6bdcd883a05a0e55..d02890ccae53b1286cc29ab6104d472f8d10458b 100644 --- a/module/VuFindConsole/config/module.config.php +++ b/module/VuFindConsole/config/module.config.php @@ -59,7 +59,7 @@ $routes = [ 'util/index_reserves' => 'util index_reserves [--help|-h] [-d=s] [-t=s] [-f=s]', 'util/optimize' => 'util optimize [<core>]', 'util/sitemap' => 'util sitemap', - 'util/suppressed' => 'util suppressed [--help|-h] [--authorities]', + 'util/suppressed' => 'util suppressed [--help|-h] [--authorities] [--outfile=s]', 'util/switch_db_hash' => 'util switch_db_hash [<newhash>] [<newkey>]', ]; diff --git a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php index 26e23f639578505d0f1308a8e743b67c46d1ef1f..ba7f0c2c74acbe8fcfc35daff2beb35d6bb28aab 100644 --- a/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php +++ b/module/VuFindConsole/src/VuFindConsole/Controller/UtilController.php @@ -539,6 +539,10 @@ class UtilController extends AbstractBase . ' Delete authority records instead of bibliographic records' ); Console::writeLine('--help or -h => Show this message'); + Console::writeLine( + '--outfile=[/path/to/file] => Write the ID list to the specified' + . ' file instead of updating Solr (optional)' + ); return $this->getFailureResponse(); } @@ -565,11 +569,19 @@ class UtilController extends AbstractBase return $this->getSuccessResponse(); } - // Get Suppressed Records and Delete from index - $solr = $this->serviceLocator->get('VuFind\Solr\Writer'); - $solr->deleteRecords($backend, $result); - $solr->commit($backend); - $solr->optimize($backend); + // If 'outfile' set, write the list + if ($file = $request->getParam('outfile')) { + if (!file_put_contents($file, implode("\n", $result))) { + Console::writeLine("Problem writing to $file"); + return $this->getFailureResponse(); + } + } else { + // Default behavior: Get Suppressed Records and Delete from index + $solr = $this->serviceLocator->get('VuFind\Solr\Writer'); + $solr->deleteRecords($backend, $result); + $solr->commit($backend); + $solr->optimize($backend); + } return $this->getSuccessResponse(); }