Skip to content

Commit

Permalink
Merge pull request #2906 from 10up/burhan/fix-2868
Browse files Browse the repository at this point in the history
Fix: recreate-network-alias throw error on single site
  • Loading branch information
felipeelia committed Jul 26, 2022
2 parents 40a8102 + 4400853 commit ff23083
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
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

0 comments on commit ff23083

Please sign in to comment.