Jake B.
Well-known member
- Affected version
- 2.2.6
Currently if you rebuild the search index it's either all or one at a time, which can be a bit of a pain if you need to (for example) search index for all XFMG data, for example. Able to work around this to have multiple types specified in CLI without breaking or changing how the web rebuild works:
Diff:
diff --git a/src/XF/Cli/Command/Rebuild/RebuildSearch.php b/src/XF/Cli/Command/Rebuild/RebuildSearch.php
index 4897636f6..3f2e59248 100644
--- a/src/XF/Cli/Command/Rebuild/RebuildSearch.php
+++ b/src/XF/Cli/Command/Rebuild/RebuildSearch.php
@@ -27,7 +27,7 @@ class RebuildSearch extends AbstractRebuildCommand
->addOption(
'type',
null,
- InputOption::VALUE_REQUIRED,
+ InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED,
'Content type to rebuild search index for. Default: all'
)
->addOption(
diff --git a/src/XF/Job/SearchRebuild.php b/src/XF/Job/SearchRebuild.php
index 422dcca73..88fc315eb 100644
--- a/src/XF/Job/SearchRebuild.php
+++ b/src/XF/Job/SearchRebuild.php
@@ -28,7 +28,7 @@ class SearchRebuild extends AbstractJob
if (!is_array($this->data['rebuild_types']))
{
- $this->data['rebuild_types'] = $this->data['type'] ? [$this->data['type']] : $search->getAvailableTypes();
+ $this->data['rebuild_types'] = $this->data['type'] ? (is_array($this->data['type']) ? $this->data['type'] : [$this->data['type']]) : $search->getAvailableTypes();
$this->data['type'] = null;
}
Code:
xf xf-rebuild:search --type=post --type=profile_post
Rebuilding... Search index (Post 18)
Rebuilding... Search index
Rebuilding... Search index (Profile post 15)
Rebuilding... Search index