From: Eugene Ware Date: Wed, 26 Jun 2013 06:37:16 +0000 (+1000) Subject: Make wp rewrite (flush|structure) generate .htaccess files properly for apache. X-Git-Tag: v0.11.0~54^2~3 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=91d4521d62723bccac68901bdc7968b5429ed25f;p=wvm%2Fwvm.git Make wp rewrite (flush|structure) generate .htaccess files properly for apache. --- diff --git a/php/commands/rewrite.php b/php/commands/rewrite.php index 7f464ae0..3453496e 100644 --- a/php/commands/rewrite.php +++ b/php/commands/rewrite.php @@ -10,16 +10,18 @@ class Rewrite_Command extends WP_CLI_Command { /** * Flush rewrite rules. * - * @synopsis [--soft] + * @synopsis [--hard] */ public function flush( $args, $assoc_args ) { - flush_rewrite_rules( isset( $assoc_args['soft'] ) ); + // make sure we detect mod_rewrite if configured in apache_modules in config + self::apache_modules(); + flush_rewrite_rules( isset( $assoc_args['hard'] ) ); } /** * Update the permalink structure. * - * @synopsis [--category-base=] [--tag-base=] + * @synopsis [--category-base=] [--tag-base=] [--hard] */ public function structure( $args, $assoc_args ) { global $wp_rewrite; @@ -62,7 +64,9 @@ class Rewrite_Command extends WP_CLI_Command { $wp_rewrite->set_tag_base( $tag_base ); } - flush_rewrite_rules( $hard ); + // make sure we detect mod_rewrite if configured in apache_modules in config + self::apache_modules(); + flush_rewrite_rules( isset( $assoc_args['hard'] ) ); } /** @@ -86,6 +90,22 @@ class Rewrite_Command extends WP_CLI_Command { } } + + /** + * Expose apache modules if present in config + */ + public static function apache_modules() { + $mods = WP_CLI::get_config('apache_modules'); + if ( count($mods) > 0 && !function_exists( 'apache_get_modules') ) { + global $is_apache; + $is_apache = true; + + function apache_get_modules() { + return WP_CLI::get_config('apache_modules'); + } + } + } + } WP_CLI:: add_command( 'rewrite', 'Rewrite_Command' ); diff --git a/php/config-spec.php b/php/config-spec.php index 61aaf46b..1ec7556f 100644 --- a/php/config-spec.php +++ b/php/config-spec.php @@ -63,5 +63,12 @@ return array( 'default' => false, 'desc' => 'Suppress informational messages', ), + + 'apache_modules' => array( + 'file' => '', + 'desc' => 'List of Apache Modules that are to be reported as loaded', + 'multiple' => true, + 'default' => array(), + ), );