Skip to content

Commit

Permalink
Some cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkyKZ committed Nov 13, 2019
1 parent 0e95b5b commit c434273
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions plugins/system/cache/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
defined('_JEXEC') or die;

use Joomla\CMS\Cache\Cache;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Profiler\Profiler;
Expand All @@ -26,7 +25,7 @@ class PlgSystemCache extends CMSPlugin
/**
* Cache instance.
*
* @var JCache
* @var \Joomla\CMS\Cache\CacheController
* @since 1.5
*/
public $_cache;
Expand All @@ -42,7 +41,7 @@ class PlgSystemCache extends CMSPlugin
/**
* Application object.
*
* @var JApplicationCms
* @var \Joomla\CMS\Application\CMSApplication
* @since 3.8.0
*/
protected $app;
Expand All @@ -55,16 +54,10 @@ class PlgSystemCache extends CMSPlugin
*
* @since 1.5
*/
public function __construct(& $subject, $config)
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);

// Get the application if not done by JPlugin. This may happen during upgrades from Joomla 2.5.
if (!isset($this->app))
{
$this->app = Factory::getApplication();
}

// Set the cache options.
$options = array(
'defaultgroup' => 'page',
Expand Down Expand Up @@ -122,7 +115,7 @@ public function onAfterInitialise()
$results = $this->app->triggerEvent('onPageCacheSetCaching');
$caching = !in_array(false, $results, true);

if ($caching && Factory::getUser()->guest && $this->app->input->getMethod() === 'GET')
if ($caching && $this->app->getIdentity()->guest && $this->app->input->getMethod() === 'GET')
{
$this->_cache->setCaching(true);
}
Expand All @@ -138,8 +131,7 @@ public function onAfterInitialise()
// Dumps HTML page.
echo $this->app->toString((bool) $this->app->get('gzip'));

// Mark afterCache in debug and run debug onAfterRespond events.
// e.g., show Joomla Debug Console if debug is active.
// Mark afterCache in debug and run debug onAfterRespond events, e.g. show Joomla Debug Console if debug is active.
if (JDEBUG)
{
Profiler::getInstance('Application')->mark('afterCache');
Expand Down Expand Up @@ -168,7 +160,7 @@ public function onAfterRender()

// We need to check if user is guest again here, because auto-login plugins have not been fired before the first aid check.
// Page is excluded if excluded in plugin settings.
if (!JFactory::getUser()->guest || $this->app->getMessageQueue() || $this->isExcluded() === true)
if (!$this->app->getIdentity()->guest || $this->app->getMessageQueue() || $this->isExcluded() === true)
{
$this->_cache->setCaching(false);

Expand Down

0 comments on commit c434273

Please sign in to comment.