Made_Cache - Version 1.4.3

Version Notes

N/A

Download this release

Release Info

Developer Jonathan Selander
Extension Made_Cache
Version 1.4.3
Comparing to
See all releases


Code changes from version 1.4.2 to 1.4.3

app/code/community/Made/Cache/Helper/Varnish.php CHANGED
@@ -65,6 +65,22 @@ class Made_Cache_Helper_Varnish extends Mage_Core_Helper_Abstract
65
  return $this->_callVarnish('', 'FLUSH');
66
  }
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  /**
69
  * Purge specific object in varnish cache
70
  *
65
  return $this->_callVarnish('', 'FLUSH');
66
  }
67
 
68
+ /**
69
+ * Bans an URL or more from the Varnish cache
70
+ *
71
+ * @param string|array $urls
72
+ */
73
+ public function ban($urls)
74
+ {
75
+ $urls = (array)$urls;
76
+ $status = array();
77
+ foreach ($urls as $url) {
78
+ $header = 'X-Ban-String: req.url ~ ' . $url;
79
+ $status = array_merge($this->_callVarnish('/', 'BAN', array($header)), $status);
80
+ }
81
+ return $status;
82
+ }
83
+
84
  /**
85
  * Purge specific object in varnish cache
86
  *
app/code/community/Made/Cache/Model/Observer.php CHANGED
@@ -71,8 +71,10 @@ class Made_Cache_Model_Observer
71
  public function reviewSaveAfter(Varien_Event_Observer $observer)
72
  {
73
  $_object = $observer->getObject();
74
- $_productCollection = $_object->getProductCollection();
75
-
 
 
76
  foreach ($_productCollection as $_product) {
77
  $_product->cleanCache();
78
  }
@@ -88,10 +90,20 @@ class Made_Cache_Model_Observer
88
  $invalidatedTypes = Mage::app()->getCacheInstance()
89
  ->getInvalidatedTypes();
90
 
91
- if (is_array($invalidatedTypes) &&
92
- isset($invalidatedTypes[Mage_Core_Block_Abstract::CACHE_GROUP])) {
93
- Mage::app()->getCacheInstance()
94
- ->cleanType(Mage_Core_Block_Abstract::CACHE_GROUP);
 
 
 
 
 
 
 
 
 
 
95
  }
96
  }
97
 
71
  public function reviewSaveAfter(Varien_Event_Observer $observer)
72
  {
73
  $_object = $observer->getObject();
74
+ $_productCollection = $_object->getProductCollection()
75
+ ->addAttributeToFilter('rt.review_id',
76
+ array('eq' => $_object->getId()));
77
+
78
  foreach ($_productCollection as $_product) {
79
  $_product->cleanCache();
80
  }
90
  $invalidatedTypes = Mage::app()->getCacheInstance()
91
  ->getInvalidatedTypes();
92
 
93
+ if (!is_array($invalidatedTypes)) {
94
+ return;
95
+ }
96
+
97
+ $typesToCheck = array(
98
+ Mage_Core_Block_Abstract::CACHE_GROUP,
99
+ 'full_page'
100
+ );
101
+
102
+ foreach ($typesToCheck as $type) {
103
+ if (isset($invalidatedTypes[Mage_Core_Block_Abstract::CACHE_GROUP])) {
104
+ Mage::app()->getCacheInstance()
105
+ ->cleanType($type);
106
+ }
107
  }
108
  }
109
 
app/code/community/Made/Cache/Model/Observer/Catalog.php CHANGED
@@ -105,8 +105,25 @@ class Made_Cache_Model_Observer_Catalog
105
  $this->_getCategoryIdForProductList($block);
106
 
107
  // The toolbar needs to apply sort order etc
108
- $productCollection = $block->getLoadedProductCollection();
109
  $_toolbar = $block->getToolbarBlock();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  $_toolbar->setCollection($productCollection);
111
 
112
  foreach ($productCollection as $_product) {
105
  $this->_getCategoryIdForProductList($block);
106
 
107
  // The toolbar needs to apply sort order etc
 
108
  $_toolbar = $block->getToolbarBlock();
109
+ $productCollection = $block->getLoadedProductCollection();
110
+
111
+ /**
112
+ * @see Mage_Catalog_Block_Product_List_Toolbar::getCurrentOrder
113
+ */
114
+ if ($orders = $block->getAvailableOrders()) {
115
+ $_toolbar->setAvailableOrders($orders);
116
+ }
117
+ if ($sort = $block->getSortBy()) {
118
+ $_toolbar->setDefaultOrder($sort);
119
+ }
120
+ if ($dir = $block->getDefaultDirection()) {
121
+ $_toolbar->setDefaultDirection($dir);
122
+ }
123
+ if ($modes = $block->getModes()) {
124
+ $_toolbar->setModes($modes);
125
+ }
126
+
127
  $_toolbar->setCollection($productCollection);
128
 
129
  foreach ($productCollection as $_product) {
app/code/community/Made/Cache/Model/VarnishObserver.php CHANGED
@@ -195,13 +195,17 @@ class Made_Cache_Model_VarnishObserver
195
 
196
  if (!empty($relativeUrls)) {
197
  $relativeUrls = array_unique($relativeUrls);
198
- $errors = Mage::helper('cache/varnish')->purge($relativeUrls);
199
- if (!empty($errors)) {
200
- Mage::getSingleton('adminhtml/session')->addError(
201
- "Some Varnish purges failed: <br/>" . implode("<br/>", $errors));
202
- } else {
203
- Mage::getSingleton('adminhtml/session')->addSuccess(
204
- "The following URLs have been cleared from Varnish: <br/>&nbsp;&nbsp;" . implode(", ", $relativeUrls));
 
 
 
 
205
  }
206
  }
207
 
195
 
196
  if (!empty($relativeUrls)) {
197
  $relativeUrls = array_unique($relativeUrls);
198
+ $errors = Mage::helper('cache/varnish')->ban($relativeUrls);
199
+
200
+ // Varnish purge messages should only appear in the backend
201
+ if (Mage::app()->getStore()->isAdmin()) {
202
+ if (!empty($errors)) {
203
+ Mage::getSingleton('adminhtml/session')->addError(
204
+ "Some Varnish purges failed: <br/>" . implode("<br/>", $errors));
205
+ } else {
206
+ Mage::getSingleton('adminhtml/session')->addSuccess(
207
+ "The following URLs have been cleared from Varnish: <br/>&nbsp;&nbsp;" . implode(", ", $relativeUrls));
208
+ }
209
  }
210
  }
211
 
app/code/community/Made/Cache/etc/config.xml CHANGED
@@ -9,7 +9,7 @@
9
  <config>
10
  <modules>
11
  <Made_Cache>
12
- <version>1.4.2</version>
13
  </Made_Cache>
14
  </modules>
15
  <global>
@@ -48,15 +48,6 @@
48
  </core>
49
  </blocks>
50
  <events>
51
- <adminhtml_cache_flush_all>
52
- <observers>
53
- <varnish_purge>
54
- <type>singleton</type>
55
- <class>cache/varnishObserver</class>
56
- <method>purge</method>
57
- </varnish_purge>
58
- </observers>
59
- </adminhtml_cache_flush_all>
60
  <application_clean_cache>
61
  <observers>
62
  <varnish_purge>
@@ -93,24 +84,6 @@
93
  </quote_save_after>
94
  </observers>
95
  </sales_quote_save_after>
96
- <review_save_after>
97
- <observers>
98
- <cache_review_save_after>
99
- <type>singleton</type>
100
- <class>cache/observer</class>
101
- <method>reviewSaveAfter</method>
102
- </cache_review_save_after>
103
- </observers>
104
- </review_save_after>
105
- <controller_action_postdispatch_adminhtml_catalog_product_save>
106
- <observers>
107
- <clean_cache_after_product_save>
108
- <type>singleton</type>
109
- <class>cache/observer</class>
110
- <method>cleanCacheAfterProductSave</method>
111
- </clean_cache_after_product_save>
112
- </observers>
113
- </controller_action_postdispatch_adminhtml_catalog_product_save>
114
  </events>
115
  </global>
116
  <frontend>
@@ -199,6 +172,35 @@
199
  </events>
200
  </frontend>
201
  <adminhtml>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  <acl>
203
  <resources>
204
  <admin>
9
  <config>
10
  <modules>
11
  <Made_Cache>
12
+ <version>1.4.3</version>
13
  </Made_Cache>
14
  </modules>
15
  <global>
48
  </core>
49
  </blocks>
50
  <events>
 
 
 
 
 
 
 
 
 
51
  <application_clean_cache>
52
  <observers>
53
  <varnish_purge>
84
  </quote_save_after>
85
  </observers>
86
  </sales_quote_save_after>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  </events>
88
  </global>
89
  <frontend>
172
  </events>
173
  </frontend>
174
  <adminhtml>
175
+ <events>
176
+ <controller_action_postdispatch_adminhtml_catalog_product_save>
177
+ <observers>
178
+ <clean_cache_after_product_save>
179
+ <type>singleton</type>
180
+ <class>cache/observer</class>
181
+ <method>cleanCacheAfterProductSave</method>
182
+ </clean_cache_after_product_save>
183
+ </observers>
184
+ </controller_action_postdispatch_adminhtml_catalog_product_save>
185
+ <adminhtml_cache_flush_all>
186
+ <observers>
187
+ <varnish_purge>
188
+ <type>singleton</type>
189
+ <class>cache/varnishObserver</class>
190
+ <method>purge</method>
191
+ </varnish_purge>
192
+ </observers>
193
+ </adminhtml_cache_flush_all>
194
+ <review_save_after>
195
+ <observers>
196
+ <cache_review_save_after>
197
+ <type>singleton</type>
198
+ <class>cache/observer</class>
199
+ <method>reviewSaveAfter</method>
200
+ </cache_review_save_after>
201
+ </observers>
202
+ </review_save_after>
203
+ </events>
204
  <acl>
205
  <resources>
206
  <admin>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Made_Cache</name>
4
- <version>1.4.2</version>
5
  <stability>stable</stability>
6
  <license>4-clause BSD License</license>
7
  <channel>community</channel>
@@ -18,9 +18,9 @@ ESI is supported in conjunction with Phoenix_VarnishCache, and allows for super-
18
  A good block cache is vital for scaling a site, be sure to implement it before residing to full page cache.</description>
19
  <notes>N/A</notes>
20
  <authors><author><name>Jonathan Selander</name><user>jonathan_made</user><email>info@madepeople.se</email></author></authors>
21
- <date>2012-11-22</date>
22
- <time>18:14:36</time>
23
- <contents><target name="magecommunity"><dir name="Made"><dir name="Cache"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="List"><file name="Product.php" hash="6356fde9c5acf5f0a96851e780a691b1"/></dir><file name="List.php" hash="bb1e30501c95e83901de75bcb780d072"/></dir></dir><file name="Messages.php" hash="6d7eaed6a93c0deb6037ea36e88ec62f"/><file name="Profiler.php" hash="7d1fd856f08a1900b15a72ae46eb143d"/><dir name="Varnish"><file name="Footer.php" hash="4da9584f4cf4b70149b5c48f9657f668"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6ea193010f6bf79c0c92f06d15e8d73b"/><file name="Varnish.php" hash="5a96d2731d02dc8b7e311b6fd9e276f7"/></dir><dir name="Model"><file name="Layout.php" hash="d77634d026ebc8e228d3c80b7c5caff7"/><dir name="Observer"><file name="Abstract.php" hash="e9f870d8766e1b2e5c6c091052565731"/><file name="Catalog.php" hash="39e069dd45ef75d2ab5b00c708181567"/><file name="Checkout.php" hash="4f6cc6aa7b2466976cad6c25f6a466e5"/><file name="Cms.php" hash="7bac2c6d57d3ff85d397c7cc1867c323"/></dir><file name="Observer.php" hash="8e641fbc376853a6237e0271288b0e4a"/><file name="Profiler.php" hash="888d3e38e212d872a4420a3556ca4b08"/><file name="VarnishObserver.php" hash="05001405131288db87b2abbe70a780b0"/></dir><dir name="controllers"><file name="VarnishController.php" hash="507120591d2e0ad6b33e7816f2c654cd"/></dir><dir name="etc"><file name="config.xml" hash="4ebff803771d6609ac0574aaa864bf59"/><file name="magento.vcl" hash="a247cd54d96f824bacacda6704ad5285"/><file name="system.xml" hash="4ffc1ded6a50a61aeaf932c5a3556a28"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Made_Cache.xml" hash="4cf53cc9b4e525eb560f7fe1278d96bd"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="madecache.xml" hash="7651f67cbe8ee0cd36519684ac74e68f"/></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
26
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Made_Cache</name>
4
+ <version>1.4.3</version>
5
  <stability>stable</stability>
6
  <license>4-clause BSD License</license>
7
  <channel>community</channel>
18
  A good block cache is vital for scaling a site, be sure to implement it before residing to full page cache.</description>
19
  <notes>N/A</notes>
20
  <authors><author><name>Jonathan Selander</name><user>jonathan_made</user><email>info@madepeople.se</email></author></authors>
21
+ <date>2013-01-02</date>
22
+ <time>11:52:48</time>
23
+ <contents><target name="magecommunity"><dir name="Made"><dir name="Cache"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="List"><file name="Product.php" hash="6356fde9c5acf5f0a96851e780a691b1"/></dir><file name="List.php" hash="bb1e30501c95e83901de75bcb780d072"/></dir></dir><file name="Messages.php" hash="6d7eaed6a93c0deb6037ea36e88ec62f"/><file name="Profiler.php" hash="7d1fd856f08a1900b15a72ae46eb143d"/><dir name="Varnish"><file name="Footer.php" hash="4da9584f4cf4b70149b5c48f9657f668"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6ea193010f6bf79c0c92f06d15e8d73b"/><file name="Varnish.php" hash="8bcd2b055a979e7105f1572c830cd43e"/></dir><dir name="Model"><file name="Layout.php" hash="d77634d026ebc8e228d3c80b7c5caff7"/><dir name="Observer"><file name="Abstract.php" hash="e9f870d8766e1b2e5c6c091052565731"/><file name="Catalog.php" hash="6dfa4a5ad45fb62ea3761c0c30b1d001"/><file name="Checkout.php" hash="4f6cc6aa7b2466976cad6c25f6a466e5"/><file name="Cms.php" hash="7bac2c6d57d3ff85d397c7cc1867c323"/></dir><file name="Observer.php" hash="fda6e61d165196e8e9941585c1648dd5"/><file name="Profiler.php" hash="888d3e38e212d872a4420a3556ca4b08"/><file name="VarnishObserver.php" hash="612bd3b8f48fe88ed3567096cbf439a4"/></dir><dir name="controllers"><file name="VarnishController.php" hash="507120591d2e0ad6b33e7816f2c654cd"/></dir><dir name="etc"><file name="config.xml" hash="893164b8bc28e105c69e17120b38fc73"/><file name="magento.vcl" hash="a247cd54d96f824bacacda6704ad5285"/><file name="system.xml" hash="4ffc1ded6a50a61aeaf932c5a3556a28"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Made_Cache.xml" hash="4cf53cc9b4e525eb560f7fe1278d96bd"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="madecache.xml" hash="7651f67cbe8ee0cd36519684ac74e68f"/></dir></dir></dir></dir></target></contents>
24
  <compatible/>
25
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
26
  </package>