From 3d983d8377b6e499d91fbbb04437beb7e900406c Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Mon, 13 Oct 2014 10:38:11 -0700 Subject: [PATCH 1/3] Forcing a hard clear-cache for self upgrade only and soft clear-cache for install/update of themes/plugins --- system/src/Grav/Console/ConsoleTrait.php | 8 ++++++-- system/src/Grav/Console/Gpm/InstallCommand.php | 3 +++ system/src/Grav/Console/Gpm/SelfupgradeCommand.php | 3 +-- system/src/Grav/Console/Gpm/UpdateCommand.php | 3 +++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Console/ConsoleTrait.php b/system/src/Grav/Console/ConsoleTrait.php index 1067331ee..7770ecbbd 100644 --- a/system/src/Grav/Console/ConsoleTrait.php +++ b/system/src/Grav/Console/ConsoleTrait.php @@ -64,10 +64,14 @@ trait ConsoleTrait } } - public function clearCache() + public function clearCache($all = []) { + if ($all) { + $all = ['--all' => true]; + } + $command = new ClearCacheCommand(); - $input = new ArrayInput(array('--all' => true)); + $input = new ArrayInput($all); return $command->run($input, $this->output); } } diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index 6c5a124fa..aacfd3c86 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -114,6 +114,9 @@ class InstallCommand extends Command } } } + + // clear cache after successful upgrade + $this->clearCache(); } private function downloadPackage($package) diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index 3cb0f423b..455eea9b9 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -7,7 +7,6 @@ use Grav\Common\GPM\Installer; use Grav\Common\GPM\Response; use Grav\Console\ConsoleTrait; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -117,7 +116,7 @@ class SelfupgradeCommand extends Command } // clear cache after successful upgrade - $this->clearCache(); + $this->clearCache(true); } private function download($package) diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index 87c91c36e..451a3e79a 100644 --- a/system/src/Grav/Console/Gpm/UpdateCommand.php +++ b/system/src/Grav/Console/Gpm/UpdateCommand.php @@ -128,6 +128,9 @@ class UpdateCommand extends Command $this->output->writeln("Error: An error occured while trying to install the extensions"); exit; } + + // clear cache after successful upgrade + $this->clearCache(); } private function userInputPackages($onlyPackages) From d18f0bf7517eeee65b682e877232d49553be019d Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Mon, 13 Oct 2014 14:24:55 -0700 Subject: [PATCH 2/3] Removed is_file check on the else statement as files with no extensions aren't recognized as files by PHP, preventing .htaccess or LICENSE to get copied over --- system/src/Grav/Common/GPM/Installer.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index dc2d563c2..36cce7867 100644 --- a/system/src/Grav/Common/GPM/Installer.php +++ b/system/src/Grav/Common/GPM/Installer.php @@ -150,10 +150,8 @@ class Installer } } } else { - if (is_file($path)) { - @unlink($path); - @copy($tmp . DS . $filename, $path); - } + @unlink($path); + @copy($tmp . DS . $filename, $path); } } } From 9fa92b504f47a51c24a51be1b96b7bbbc2ad7452 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 14 Oct 2014 12:47:47 -0600 Subject: [PATCH 3/3] Admin check --- system/src/Grav/Common/Plugin.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index 1b4a42769..e7b6bc481 100644 --- a/system/src/Grav/Common/Plugin.php +++ b/system/src/Grav/Common/Plugin.php @@ -23,6 +23,8 @@ class Plugin implements EventSubscriberInterface */ protected $config; + protected $active = true; + /** * By default assign all methods as listeners using the default priority. * @@ -53,6 +55,14 @@ class Plugin implements EventSubscriberInterface $this->config = $config; } + public function isAdmin() + { + if (isset($this->grav['admin'])) { + return true; + } + return false; + } + /** * @param array $events */