Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: recreate-network-alias throw error on single site #2906

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,10 @@ public function recreate_network_alias( $args, $assoc_args ) {
$this->connect_check();
$this->index_occurring();

if ( ! defined( 'EP_IS_NETWORK' ) || ! EP_IS_NETWORK ) {
WP_CLI::error( esc_html__( 'ElasticPress is not network activated.', 'elasticpress' ) );
}

$indexables = Indexables::factory()->get_all( false );

foreach ( $indexables as $indexable ) {
Expand Down
6 changes: 6 additions & 0 deletions tests/cypress/integration/wp-cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ describe('WP-CLI Commands', () => {

it('Can recreate the alias index which points to every index in the network if user runs wp elasticpress recreate-network-alias command', () => {});

it('Can throw an error while running wp elasticpress recreate-network-alias if the plugin is not network activated', () => {
cy.wpCli('wp elasticpress recreate-network-alias', true)
.its('stderr')
.should('contain', 'ElasticPress is not network activated');
});

it('Can activate and deactivate a feature', () => {
cy.wpCli('wp elasticpress activate-feature search', true)
.its('stderr')
Expand Down