Skip to content

Commit

Permalink
Fixes an issue where CP Clear Cache could conflict with other plugins…
Browse files Browse the repository at this point in the history
…. Bump to 1.0.5
  • Loading branch information
mmikkel committed Oct 21, 2019
1 parent 7113342 commit 1530b4c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.5 - 2019-10-21
### Fixed
- Fixes an issue where CP Clear Cache could conflict with other plugins

## 1.0.4 - 2019-03-27
### Fixed
- Fixes an issue where CP Clear Cache could conflict with other plugins
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mmikkel/cp-clearcache",
"description": "Less clickin’ to get clearin’",
"type": "craft-plugin",
"version": "1.0.4",
"version": "1.0.5",
"keywords": [
"craft",
"cms",
Expand Down
19 changes: 17 additions & 2 deletions src/CpClearCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,20 @@ public function init()
parent::init();
self::$plugin = $this;

if (Craft::$app->getRequest()->getIsConsoleRequest() || !Craft::$app->getUser()->getIdentity() || !Craft::$app->getRequest()->getIsCpRequest()) {
$request = Craft::$app->getRequest();

if (!$request->getIsCpRequest() || $request->getIsConsoleRequest()) {
return;
}

Craft::$app->on(Application::EVENT_INIT, [$this, 'doIt']);
// Handler: EVENT_AFTER_LOAD_PLUGINS
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_LOAD_PLUGINS,
function () {
$this->doIt();
}
);

}

Expand All @@ -76,6 +85,12 @@ public function init()
*/
protected function doIt()
{

$user = Craft::$app->getUser();
if (!$user->id) {
return;
}

$utilitiesService = Craft::$app->getUtilities();

/** @var UtilityInterface $clearCachesUtility */
Expand Down

0 comments on commit 1530b4c

Please sign in to comment.