Skip to content

Commit

Permalink
Now that we have a method to launch new WP-CLI processes, use it to f…
Browse files Browse the repository at this point in the history
…lush rewrite rules after setting the structure.

Fixes #814
  • Loading branch information
danielbachhuber committed Nov 22, 2013
1 parent 9d532c0 commit 3be1d98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 0 additions & 1 deletion features/rewrite.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Feature: Manage WordPress rewrites

Scenario: Change site permastructs
When I run `wp rewrite structure /blog/%year%/%monthnum%/%day%/%postname%/ --category-base=section --tag-base=topic`
And I run `wp rewrite flush`

When I run `wp option get permalink_structure`
Then STDOUT should contain:
Expand Down
9 changes: 8 additions & 1 deletion php/commands/rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ public function structure( $args, $assoc_args ) {

// make sure we detect mod_rewrite if configured in apache_modules in config
self::apache_modules();
flush_rewrite_rules( isset( $assoc_args['hard'] ) );

// Launch a new process to flush rewrites because core expects flush
// to happen after rewrites are set
$new_assoc_args = array();
if ( isset( $assoc_args['hard'] ) )
$new_assoc_args['hard'] = true;
\WP_CLI::launch_wpcli( 'rewrite flush', array(), $new_assoc_args );

WP_CLI::success( "Rewrite structure set." );
}

Expand Down

0 comments on commit 3be1d98

Please sign in to comment.