Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #349 from metfan/master

add use of flush option in doctrine:clear_* task
  • Loading branch information...
commit dffab3aa48a69b3b78d1d485c3f31a469b70dc7c 2 parents a70e94d + f9c0865
@willdurand willdurand authored
View
3  lib/capifony_symfony2.rb 100644 → 100755
@@ -114,6 +114,9 @@ def self.load_into(configuration)
# Doctrine custom entity manager
set :doctrine_em, false
+
+ # Use --flush option in doctrine:clear_* task
+ set :doctrine_clear_use_flush_option, false
# Symfony2 version
set(:symfony_version) { guess_symfony_version }
View
24 lib/symfony2/doctrine.rb 100644 → 100755
@@ -5,7 +5,13 @@
task :clear_metadata, :roles => :app, :except => { :no_release => true } do
capifony_pretty_print "--> Clearing Doctrine metadata cache"
- run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-metadata --env=#{symfony_env_prod}#{doctrine_em_flag}'"
+ if doctrine_clear_use_flush_option
+ flush_option = " --flush"
+ else
+ flush_option = ""
+ end
+
+ run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-metadata --env=#{symfony_env_prod}#{doctrine_em_flag}#{flush_option}'"
capifony_puts_ok
end
@@ -13,7 +19,13 @@
task :clear_query, :roles => :app, :except => { :no_release => true } do
capifony_pretty_print "--> Clearing Doctrine query cache"
- run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-query --env=#{symfony_env_prod}#{doctrine_em_flag}'"
+ if doctrine_clear_use_flush_option
+ flush_option = " --flush"
+ else
+ flush_option = ""
+ end
+
+ run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-query --env=#{symfony_env_prod}#{doctrine_em_flag}#{flush_option}'"
capifony_puts_ok
end
@@ -21,7 +33,13 @@
task :clear_result, :roles => :app, :except => { :no_release => true } do
capifony_pretty_print "--> Clearing Doctrine result cache"
- run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-result --env=#{symfony_env_prod}#{doctrine_em_flag}'"
+ if doctrine_clear_use_flush_option
+ flush_option = " --flush"
+ else
+ flush_option = ""
+ end
+
+ run "#{try_sudo} sh -c 'cd #{latest_release} && #{php_bin} #{symfony_console} doctrine:cache:clear-result --env=#{symfony_env_prod}#{doctrine_em_flag}#{flush_option}'"
capifony_puts_ok
end
end
View
14 spec/capifony_symfony2_doctrine_spec.rb 100644 → 100755
@@ -207,5 +207,19 @@
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:fixtures:load --env=prod --em=custom_em\'') }
it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:migrations:status --env=prod --em=custom_em\'') }
end
+
+ context "when running symfony:doctrine:clear_* with flush option" do
+ before do
+ @configuration.set :doctrine_clear_use_flush_option, true
+
+ @configuration.find_and_execute_task('symfony:doctrine:cache:clear_metadata')
+ @configuration.find_and_execute_task('symfony:doctrine:cache:clear_query')
+ @configuration.find_and_execute_task('symfony:doctrine:cache:clear_result')
+ end
+
+ it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:cache:clear-metadata --env=prod --flush\'') }
+ it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:cache:clear-query --env=prod --flush\'') }
+ it { should have_run(' sh -c \'cd /var/www/releases/20120927 && php app/console doctrine:cache:clear-result --env=prod --flush\'') }
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.