Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush Magento Cache doesn't do anything #345

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: fballiano
buy_me_a_coffee: fballiano
custom: ["https://paypal.me/fabrizioballiano"]
32 changes: 7 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,34 @@

[![Latest Release][ico-version]][link-release]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-coverall]][link-coveralls]

Simple Magento Fullpagecache. The current documentation can be found
PHP FullPageCache for OpenMage. The current documentation can be found
[here](https://gordonlesti.com/lesti-fpc-documentationversion-1-4-5/).

## Install

Several quick start options are available:
### Install manually
* [Download the latest release](https://github.com/GordonLesti/Lesti_Fpc/releases/latest)
* [Download the latest release](https://github.com/fballiano/openmage-lesti-fpc/releases/latest)
* Unzip
* Copy `app` directory into Magento

### Install with [modman](https://github.com/colinmollenhour/modman)

```bash
modman clone https://github.com/GordonLesti/Lesti_Fpc.git
modman clone https://github.com/fballiano/openmage-lesti-fpc.git
```

### Install with [Magento Composer Installer](https://github.com/Cotya/magento-composer-installer)
* add the requirement `gordonlesti/lesti_fpc`
* add the requirement `fballiano/openmage-lesti-fpc`
```json
{
"require": {
"gordonlesti/lesti_fpc": "*"
"fballiano/openmage-lesti-fpc": "*"
}
}
```

## Change log

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [Gordon Lesti][link-author]
Expand All @@ -53,13 +39,9 @@ If you discover any security related issues, please email [email protected] i

The Open Software License v. 3.0 (OSL-3.0). Please see [License File](LICENSE.md) for more information.

[ico-version]: https://img.shields.io/github/release/GordonLesti/Lesti_Fpc.svg?style=flat-square
[ico-version]: https://img.shields.io/github/release/fballiano/openmage-lesti-fpc.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-OSL--3.0-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/GordonLesti/Lesti_Fpc/master.svg?style=flat-square
[ico-coverall]: https://img.shields.io/coveralls/GordonLesti/Lesti_Fpc/master.svg?style=flat-square

[link-release]: https://github.com/GordonLesti/Lesti_Fpc/releases/latest
[link-travis]: https://travis-ci.org/GordonLesti/Lesti_Fpc
[link-coveralls]: https://coveralls.io/r/GordonLesti/Lesti_Fpc
[link-release]: https://github.com/fballiano/openmage-lesti-fpc/releases/latest
[link-author]: https://gordonlesti.com/
[link-contributors]: ../../contributors
2 changes: 1 addition & 1 deletion app/code/community/Lesti/Fpc/Helper/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class Lesti_Fpc_Helper_Abstract extends Mage_Core_Helper_Abstract
*/
public function getCSStoreConfigs($path, $store = null)
{
$configs = trim(Mage::getStoreConfig($path, $store));
$configs = trim((string)Mage::getStoreConfig($path, $store));

if ($configs) {
return array_unique(array_map('trim', explode(',', $configs)));
Expand Down
24 changes: 8 additions & 16 deletions app/code/community/Lesti/Fpc/Model/Observer/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,18 @@ public function coreCleanCache()
$this->_getFpc()->getFrontend()->clean(Zend_Cache::CLEANING_MODE_OLD);
}

public function adminhtmlCacheFlushAll()
public function flushFpc(Varien_Event_Observer $observer)
{
$this->_getFpc()->clean();
}

public function controllerActionPredispatchAdminhtmlCacheMassRefresh()
{
$types = Mage::app()->getRequest()->getParam('types');
if ($this->_getFpc()->isActive()) {
if ((is_array($types) && in_array(self::CACHE_TYPE, $types)) ||
$types == self::CACHE_TYPE) {
$this->_getFpc()->clean();
}
// type only exist for event adminhtml_cache_refresh_type
$type = $observer->getEvent()->getData('type');
if (! empty($type) && ($type !== self::CACHE_TYPE || ! $this->_getFpc()->isActive())) {
return;
}

$this->_getFpc()->clean();
}

/**
* @return Lesti_Fpc_Model_Fpc
*/
protected function _getFpc()
protected function _getFpc(): Lesti_Fpc_Model_Fpc
{
return Mage::getSingleton('fpc/fpc');
}
Expand Down
43 changes: 18 additions & 25 deletions app/code/community/Lesti/Fpc/Test/Model/Observer/Clean.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
*/
class Lesti_Fpc_Test_Model_Observer_Clean extends Lesti_Fpc_Test_TestCase
{
/**
* @var Lesti_Fpc_Model_Observer_Clean
*/
protected $_cleanObserver;
protected Lesti_Fpc_Model_Observer_Clean $_cleanObserver;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->_cleanObserver = Mage::getSingleton('fpc/observer_clean');
}

protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
Mage::unregister('_singleton/fpc/observer_clean');
Expand Down Expand Up @@ -56,37 +53,33 @@ public function testAdminhtmlCacheFlushAll()
$this->assertFalse($this->_fpc->remove('fpc_id'));
}

/**
* @test
*/
public function testControllerActionPredispatchAdminhtmlCacheMassRefresh()
public function testAdminhtmlCacheFlushSystem()
{
$data = new \Lesti_Fpc_Model_Fpc_CacheItem('fpc_old_data', time(), 'text/html');
$this->_fpc->save($data, 'fpc_id');
Mage::dispatchEvent('adminhtml_cache_flush_system');
$this->assertFalse($this->_fpc->remove('fpc_id'));
}

public function testAdminhtmlCacheRefreshType()
{
$data = new \Lesti_Fpc_Model_Fpc_CacheItem('test_data', time(), 'text/html');

$this->_fpc->save($data, 'test_id');
Mage::app()->getRequest()->setParam('types', array('core'));
$this->_cleanObserver->
controllerActionPredispatchAdminhtmlCacheMassRefresh();
Mage::dispatchEvent('adminhtml_cache_refresh_type', ['type' => 'core']);
$this->assertEquals($data, $this->_fpc->load('test_id'));

$this->_fpc->clean();
$this->_fpc->save($data, 'test_id');
Mage::app()->getRequest()->setParam(
'types',
array('core', Lesti_Fpc_Model_Observer_Clean::CACHE_TYPE)
);
$this->_cleanObserver->
controllerActionPredispatchAdminhtmlCacheMassRefresh();
Mage::dispatchEvent('adminhtml_cache_refresh_type', ['type' => 'core']);
Mage::dispatchEvent('adminhtml_cache_refresh_type', ['type' => Lesti_Fpc_Model_Observer_Clean::CACHE_TYPE]);
$this->assertFalse($this->_fpc->load('test_id'));

$this->_fpc->clean();
$this->_fpc->save($data, 'test_id');
Mage::app()->getRequest()->setParam(
'types',
array('core', Lesti_Fpc_Model_Observer_Clean::CACHE_TYPE)
);
Mage::app()->getCacheInstance()->banUse('fpc');
$this->_cleanObserver->
controllerActionPredispatchAdminhtmlCacheMassRefresh();
Mage::dispatchEvent('adminhtml_cache_refresh_type', ['type' => 'core']);
Mage::dispatchEvent('adminhtml_cache_refresh_type', ['type' => Lesti_Fpc_Model_Observer_Clean::CACHE_TYPE]);
$this->assertEquals($data, $this->_fpc->load('test_id'));
}
}
35 changes: 20 additions & 15 deletions app/code/community/Lesti/Fpc/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<config>
<modules>
<Lesti_Fpc>
<version>1.4.8</version>
<version>1.6.0</version>
</Lesti_Fpc>
</modules>
<global>
Expand Down Expand Up @@ -117,10 +117,28 @@
<fpc_adminhtml_cache_flush_all>
<class>fpc/observer_clean</class>
<type>singleton</type>
<method>adminhtmlCacheFlushAll</method>
<method>flushFpc</method>
</fpc_adminhtml_cache_flush_all>
</observers>
</adminhtml_cache_flush_all>
<adminhtml_cache_flush_system>
<observers>
<fpc_application_cache_flush_system>
<class>fpc/observer_clean</class>
<type>singleton</type>
<method>flushFpc</method>
</fpc_application_cache_flush_system>
</observers>
</adminhtml_cache_flush_system>
<adminhtml_cache_refresh_type>
<observers>
<fpc_adminhtml_cache_refresh_type>
<class>fpc/observer_clean</class>
<type>singleton</type>
<method>flushFpc</method>
</fpc_adminhtml_cache_refresh_type>
</observers>
</adminhtml_cache_refresh_type>
<cataloginventory_stock_item_save_after>
<observers>
<fpc_cataloginventory_stock_item_save_after>
Expand Down Expand Up @@ -220,19 +238,6 @@
</updates>
</layout>
</frontend>
<adminhtml>
<events>
<controller_action_predispatch_adminhtml_cache_massRefresh>
<observers>
<fpc_controller_action_predispatch_adminhtml_cache_massRefresh>
<class>fpc/observer_clean</class>
<type>singleton</type>
<method>controllerActionPredispatchAdminhtmlCacheMassRefresh</method>
</fpc_controller_action_predispatch_adminhtml_cache_massRefresh>
</observers>
</controller_action_predispatch_adminhtml_cache_massRefresh>
</events>
</adminhtml>
<default>
<system>
<fpc>
Expand Down
1 change: 1 addition & 0 deletions app/etc/fpc.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<compress_data>1</compress_data>
<compress_tags>1</compress_tags>
<compress_data>gzip</compress_data>
<use_lua>1</use_lua>
</backend_options-->

<!-- example for apc -->
Expand Down
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "gordonlesti/lesti_fpc",
"name": "fballiano/openmage-lesti-fpc",
"type": "magento-module",
"description": "Simple Magento Fullpagecache",
"keywords": ["fpc"],
"homepage": "https://github.com/GordonLesti/Lesti_Fpc",
"homepage": "https://github.com/fballiano/openmage-lesti-fpc",
"license": "OSL-3.0",
"authors": [
{
Expand All @@ -13,9 +13,6 @@
"role": "developer"
}
],
"require": {
"magento-hackathon/magento-composer-installer": "^3.0"
},
"require-dev": {
"ecomdev/ecomdev_phpunit": "^0.3.7",
"phpunit/phpunit": "4.*",
Expand Down