Version Notes
Supports Magento v1.6 and later
Download this release
Release Info
Developer | Chris Wells |
Extension | Nexcessnet_Turpentine |
Version | 0.6.6 |
Comparing to | |
See all releases |
Code changes from version 0.6.5 to 0.6.6
- app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php +7 -1
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php +3 -1
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +38 -17
- app/code/community/Nexcessnet/Turpentine/etc/config.xml +1 -1
- app/code/community/Nexcessnet/Turpentine/etc/config.xml~ +1 -1
- app/code/community/Nexcessnet/Turpentine/etc/system.xml +10 -0
- app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl +1 -4
- app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +1 -4
- package.xml +1 -1
app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php
CHANGED
@@ -299,8 +299,14 @@ class Nexcessnet_Turpentine_Model_Observer_Ban extends Varien_Event_Observer {
|
|
299 |
*/
|
300 |
public function banProductReview( $eventObject ) {
|
301 |
$patterns = array();
|
|
|
302 |
$review = $eventObject->getObject();
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
304 |
$productIds = array_unique( array_map(
|
305 |
create_function( '$p', 'return $p->getEntityId();' ),
|
306 |
$products ) );
|
299 |
*/
|
300 |
public function banProductReview( $eventObject ) {
|
301 |
$patterns = array();
|
302 |
+
/* @var $review \Mage_Review_Model_Review*/
|
303 |
$review = $eventObject->getObject();
|
304 |
+
|
305 |
+
/* @var $productCollection \Mage_Review_Model_Resource_Review_Product_Collection*/
|
306 |
+
$productCollection = $review->getProductCollection();
|
307 |
+
|
308 |
+
$products = $productCollection->addEntityFilter((int)$review->getEntityPkValue())->getItems();
|
309 |
+
|
310 |
$productIds = array_unique( array_map(
|
311 |
create_function( '$p', 'return $p->getEntityId();' ),
|
312 |
$products ) );
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php
CHANGED
@@ -345,7 +345,9 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket {
|
|
345 |
$banner['text'] );
|
346 |
}
|
347 |
|
348 |
-
$this->_version
|
|
|
|
|
349 |
|
350 |
return $this->isConnected();
|
351 |
}
|
345 |
$banner['text'] );
|
346 |
}
|
347 |
|
348 |
+
if ($this->_version == null) { // If autodetecting
|
349 |
+
$this->_version = $this->_determineVersion($banner['text']);
|
350 |
+
}
|
351 |
|
352 |
return $this->isConnected();
|
353 |
}
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php
CHANGED
@@ -39,10 +39,10 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
|
|
39 |
return null;
|
40 |
}
|
41 |
switch( $version ) {
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
|
47 |
case '3.0':
|
48 |
return Mage::getModel(
|
@@ -209,17 +209,33 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
|
|
209 |
* @return string
|
210 |
*/
|
211 |
public function getAllowedHostsRegex() {
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
$pattern = '('.implode('|', array_map("preg_quote", $hosts)).')';
|
220 |
-
|
221 |
}
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
/**
|
224 |
* Get the base url path regex
|
225 |
*
|
@@ -292,7 +308,7 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
|
|
292 |
'first_byte_timeout' => $timeout . 's',
|
293 |
'between_bytes_timeout' => $timeout . 's',
|
294 |
);
|
295 |
-
if ( Mage::
|
296 |
return $this->_vcl_director( 'default', $default_options );
|
297 |
} else {
|
298 |
return $this->_vcl_backend( 'default',
|
@@ -313,7 +329,7 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
|
|
313 |
'first_byte_timeout' => $timeout . 's',
|
314 |
'between_bytes_timeout' => $timeout . 's',
|
315 |
);
|
316 |
-
if ( Mage::
|
317 |
return $this->_vcl_director( 'admin', $admin_options );
|
318 |
} else {
|
319 |
return $this->_vcl_backend( 'admin',
|
@@ -821,7 +837,7 @@ EOS;
|
|
821 |
'admin_frontname' => $this->_getAdminFrontname(),
|
822 |
'normalize_host_target' => $this->_getNormalizeHostTarget(),
|
823 |
'url_base_regex' => $this->getBaseUrlPathRegex(),
|
824 |
-
|
825 |
'url_excludes' => $this->_getUrlExcludes(),
|
826 |
'get_param_excludes' => $this->_getGetParamExcludes(),
|
827 |
'get_param_ignored' => $this->_getIgnoreGetParameters(),
|
@@ -857,6 +873,11 @@ EOS;
|
|
857 |
'esi_private_ttl' => Mage::helper( 'turpentine/esi' )
|
858 |
->getDefaultEsiTtl(),
|
859 |
);
|
|
|
|
|
|
|
|
|
|
|
860 |
if( Mage::getStoreConfig( 'turpentine_vcl/normalization/encoding' ) ) {
|
861 |
$vars['normalize_encoding'] = $this->_vcl_sub_normalize_encoding();
|
862 |
}
|
@@ -872,7 +893,7 @@ EOS;
|
|
872 |
if( Mage::getStoreConfig( 'turpentine_vcl/normalization/cookie_target' ) ) {
|
873 |
$vars['normalize_cookie_target'] = $this->_getNormalizeCookieTarget();
|
874 |
}
|
875 |
-
|
876 |
$customIncludeFile = $this->_getCustomIncludeFilename();
|
877 |
if( is_readable( $customIncludeFile ) ) {
|
878 |
$vars['custom_vcl_include'] = file_get_contents( $customIncludeFile );
|
39 |
return null;
|
40 |
}
|
41 |
switch( $version ) {
|
42 |
+
case '4.0':
|
43 |
+
return Mage::getModel(
|
44 |
+
'turpentine/varnish_configurator_version4',
|
45 |
+
array( 'socket' => $socket ) );
|
46 |
|
47 |
case '3.0':
|
48 |
return Mage::getModel(
|
209 |
* @return string
|
210 |
*/
|
211 |
public function getAllowedHostsRegex() {
|
212 |
+
$hosts = array();
|
213 |
+
foreach( Mage::app()->getStores() as $store ) {
|
214 |
+
$hosts[] = parse_url( $store->getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB , false ), PHP_URL_HOST );
|
215 |
+
}
|
216 |
+
|
217 |
+
$hosts = array_values(array_unique( $hosts ));
|
218 |
+
|
219 |
$pattern = '('.implode('|', array_map("preg_quote", $hosts)).')';
|
220 |
+
return $pattern;
|
221 |
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Get the Host normalization sub routine
|
225 |
+
*
|
226 |
+
* @return string
|
227 |
+
*/
|
228 |
+
protected function _vcl_sub_allowed_hosts_regex() {
|
229 |
+
$tpl = <<<EOS
|
230 |
+
# if host is not allowed in magento pass to backend
|
231 |
+
if (req.http.host !~ "{{allowed_hosts_regex}}") {
|
232 |
+
return (pass);
|
233 |
+
}
|
234 |
+
EOS;
|
235 |
+
return $this->_formatTemplate( $tpl, array(
|
236 |
+
'allowed_hosts_regex' => $this->getAllowedHostsRegex() ) );
|
237 |
+
}
|
238 |
+
|
239 |
/**
|
240 |
* Get the base url path regex
|
241 |
*
|
308 |
'first_byte_timeout' => $timeout . 's',
|
309 |
'between_bytes_timeout' => $timeout . 's',
|
310 |
);
|
311 |
+
if ( Mage::getStoreConfig( 'turpentine_vcl/backend/load_balancing' ) != 'no' ) {
|
312 |
return $this->_vcl_director( 'default', $default_options );
|
313 |
} else {
|
314 |
return $this->_vcl_backend( 'default',
|
329 |
'first_byte_timeout' => $timeout . 's',
|
330 |
'between_bytes_timeout' => $timeout . 's',
|
331 |
);
|
332 |
+
if ( Mage::getStoreConfig( 'turpentine_vcl/backend/load_balancing' ) != 'no' ) {
|
333 |
return $this->_vcl_director( 'admin', $admin_options );
|
334 |
} else {
|
335 |
return $this->_vcl_backend( 'admin',
|
837 |
'admin_frontname' => $this->_getAdminFrontname(),
|
838 |
'normalize_host_target' => $this->_getNormalizeHostTarget(),
|
839 |
'url_base_regex' => $this->getBaseUrlPathRegex(),
|
840 |
+
'allowed_hosts_regex' => $this->getAllowedHostsRegex(),
|
841 |
'url_excludes' => $this->_getUrlExcludes(),
|
842 |
'get_param_excludes' => $this->_getGetParamExcludes(),
|
843 |
'get_param_ignored' => $this->_getIgnoreGetParameters(),
|
873 |
'esi_private_ttl' => Mage::helper( 'turpentine/esi' )
|
874 |
->getDefaultEsiTtl(),
|
875 |
);
|
876 |
+
|
877 |
+
if( (bool)Mage::getStoreConfig( 'turpentine_vcl/urls/bypass_cache_store_url') ) {
|
878 |
+
$vars['allowed_hosts'] = $this->_vcl_sub_allowed_hosts_regex();
|
879 |
+
}
|
880 |
+
|
881 |
if( Mage::getStoreConfig( 'turpentine_vcl/normalization/encoding' ) ) {
|
882 |
$vars['normalize_encoding'] = $this->_vcl_sub_normalize_encoding();
|
883 |
}
|
893 |
if( Mage::getStoreConfig( 'turpentine_vcl/normalization/cookie_target' ) ) {
|
894 |
$vars['normalize_cookie_target'] = $this->_getNormalizeCookieTarget();
|
895 |
}
|
896 |
+
|
897 |
$customIncludeFile = $this->_getCustomIncludeFilename();
|
898 |
if( is_readable( $customIncludeFile ) ) {
|
899 |
$vars['custom_vcl_include'] = file_get_contents( $customIncludeFile );
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
-
<version>0.6.
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
+
<version>0.6.6</version>
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml~
CHANGED
@@ -20,7 +20,7 @@
|
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
-
<version>0.6.
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
20 |
<config>
|
21 |
<modules>
|
22 |
<Nexcessnet_Turpentine>
|
23 |
+
<version>0.6.5</version>
|
24 |
</Nexcessnet_Turpentine>
|
25 |
</modules>
|
26 |
<default>
|
app/code/community/Nexcessnet/Turpentine/etc/system.xml
CHANGED
@@ -503,6 +503,16 @@
|
|
503 |
<show_in_website>0</show_in_website>
|
504 |
<show_in_store>0</show_in_store>
|
505 |
</url_blacklist>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
506 |
</fields>
|
507 |
</urls>
|
508 |
<params translate="label" module="turpentine">
|
503 |
<show_in_website>0</show_in_website>
|
504 |
<show_in_store>0</show_in_store>
|
505 |
</url_blacklist>
|
506 |
+
<bypass_cache_store_url translate="label" module="turpentine">
|
507 |
+
<label>Bypass Varnish if base URL is not found within a store?</label>
|
508 |
+
<comment>If enabled any URL in the client that does not start with a store URL will bypass the cache</comment>
|
509 |
+
<frontend_type>select</frontend_type>
|
510 |
+
<source_model>turpentine/config_select_toggle</source_model>
|
511 |
+
<sort_order>11</sort_order>
|
512 |
+
<show_in_default>1</show_in_default>
|
513 |
+
<show_in_website>0</show_in_website>
|
514 |
+
<show_in_store>0</show_in_store>
|
515 |
+
</bypass_cache_store_url>
|
516 |
</fields>
|
517 |
</urls>
|
518 |
<params translate="label" module="turpentine">
|
app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl
CHANGED
@@ -161,10 +161,7 @@ sub vcl_recv {
|
|
161 |
error 403 "External ESI requests are not allowed";
|
162 |
}
|
163 |
}
|
164 |
-
|
165 |
-
if (req.http.host !~ "{{allowed_hosts_regex}}") {
|
166 |
-
return (pass);
|
167 |
-
}
|
168 |
# no frontend cookie was sent to us AND this is not an ESI or AJAX call
|
169 |
if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) {
|
170 |
if (client.ip ~ crawler_acl ||
|
161 |
error 403 "External ESI requests are not allowed";
|
162 |
}
|
163 |
}
|
164 |
+
{{allowed_hosts}}
|
|
|
|
|
|
|
165 |
# no frontend cookie was sent to us AND this is not an ESI or AJAX call
|
166 |
if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) {
|
167 |
if (client.ip ~ crawler_acl ||
|
app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl
CHANGED
@@ -159,10 +159,7 @@ sub vcl_recv {
|
|
159 |
return (synth(403, "External ESI requests are not allowed"));
|
160 |
}
|
161 |
}
|
162 |
-
|
163 |
-
if (req.http.host !~ "{{allowed_hosts_regex}}") {
|
164 |
-
return (pass);
|
165 |
-
}
|
166 |
# no frontend cookie was sent to us AND this is not an ESI or AJAX call
|
167 |
if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) {
|
168 |
if (client.ip ~ crawler_acl ||
|
159 |
return (synth(403, "External ESI requests are not allowed"));
|
160 |
}
|
161 |
}
|
162 |
+
{{allowed_hosts}}
|
|
|
|
|
|
|
163 |
# no frontend cookie was sent to us AND this is not an ESI or AJAX call
|
164 |
if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) {
|
165 |
if (client.ip ~ crawler_acl ||
|
package.xml
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
<?xml version='1.0' encoding='utf-8'?>
|
2 |
-
<package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>
|
1 |
<?xml version='1.0' encoding='utf-8'?>
|
2 |
+
<package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>10:26:41</time><__packager>build_package.py v0.0.3</__packager><summary>Improves Magento support for Varnish caching and generates 2.1 and 3.0 compatible VCLs.</summary><stability>stable</stability><__commit_hash>f89ae64fa0d5b415d4fcfbc1c15926d1482bcf38</__commit_hash><version>0.6.6</version><extends /><contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="a0bd4a5632b369b058c0ec5262e0cc49" name="turpentine.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="b564606032d111537d02c8da63470c39" name="varnish_management.phtml" /></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file hash="45405f2d1c0b5e915ffbd7da261d7ed0" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="50798888953fd1550e4347c39e395d0a" name="notices.phtml" /><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="02f341fdfd5194752e88cae9933cfcdb" name="ajax.phtml" /></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file hash="58848d4d90973bfd63b466ea181352a5" name="Nexcessnet_Turpentine.xml" /></dir></target><target name="magecommunity"><dir name="Nexcessnet"><dir name="Turpentine"><dir name="Helper"><file hash="7934848bff8108cfc67e34e0571bd271" name="Esi.php" /><file hash="802e269b0c80131efbb070309fdc610f" name="Varnish.php" /><file hash="913d0762f9df7696f1217f82791f1b78" name="Cron.php" /><file hash="0ee525f0fba5236f05ad2289fe2f2292" name="Data.php" /><file hash="6b637be4eac4c924fc1f02b2d49699c3" name="Ban.php" /><file hash="4a448ad2fe5b5a253a37d3f4aa3dd1bb" name="Debug.php" /></dir><dir name="misc"><file hash="70e05ae44a713d815580ddd1d51d2ebf" name="version-3.vcl" /><file hash="41bfbd36bdb9f3431bf832c1a6e0d758" name="version-4.vcl" /><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="cd7651be0ea4c3cc6635ce19c967145b" name="version-2.vcl" /></dir><dir name="etc"><file hash="007fa66fb9c56746ebe2bed297716d47" name="system.xml" /><file hash="2f1d31071be7034f6cd78083b8ac1430" name="config.xml~" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /><file hash="2d043e15c922e9cc848f6e301354284a" name="config.xml" /></dir><dir name="controllers"><file hash="3446129075986c4143e9d74d5154cf64" name="EsiController.php" /><dir name="Adminhtml"><file hash="fb44492ff908e0dd28a4fa62e382bd3e" name="CacheController.php" /></dir><dir name="Varnish"><file hash="625118bfe342139b7fd9464c05d1b0a6" name="ManagementController.php" /></dir></dir><dir name="Model"><file hash="c2cb79001524617febbfddf099d09f37" name="Session.php" /><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="9e5d87f0aa84c9fb1541db83aba69abd" name="Config.php" /><file hash="821bff6c2fb372e3ffb39abf6453b3f8" name="Layout.php" /><file hash="4a1aa246373520936f0e4b5b3a3baf25" name="App.php" /></dir></dir></dir><dir name="PageCache"><dir name="Container"><file hash="139e8a9bfa209316036e798fff654a8a" name="Notices.php" /></dir></dir><dir name="Dummy"><file hash="f6611808da53ffa00561a8f76b26016e" name="Request.php" /></dir><dir name="Varnish"><file hash="d174c8dc29d3c4ab34ac0ee57f519d76" name="Admin.php" /><dir name="Admin"><file hash="44bae0667bc3c6402a38a3015ddfe657" name="Socket.php" /></dir><dir name="Configurator"><file hash="b831b872fcb05d9c723149159db0eed1" name="Version2.php" /><file hash="82d0abe0123272e59e6c319dfdd4e9dc" name="Version3.php" /><file hash="179b9529f2eef55964d25e56b85291a7" name="Version4.php" /><file hash="e644171fb26b0ad609e5b568b8619c5b" name="Abstract.php" /></dir></dir><dir name="Observer"><file hash="89d824842dc0194a8e29e97bbdab69ac" name="Esi.php" /><file hash="7244a8ce600e980d612409595b9b6b9b" name="Varnish.php" /><file hash="a34e79218e8ca1fefad303b9399bda9d" name="Cron.php" /><file hash="e3e1542dfcf56f2353dd62e39cfd3b98" name="Ban.php" /><file hash="9d57fad69ff42b71c66ca26bc3372317" name="Debug.php" /></dir><dir name="Core"><file hash="d4f63abc6d34c923c6e64a522b6fc36e" name="Session.php" /></dir><dir name="Config"><dir name="Select"><file hash="2e01b14592189b3f6a8a05be5ef4c69c" name="StripWhitespace.php" /><file hash="15b5296a7f7bc719331f14d34308013b" name="Version.php" /><file hash="2a4648995fc87472b2ac33b35a7d69e5" name="LoadBalancing.php" /><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /></dir></dir></dir><dir name="Block"><file hash="e9b03d651a8da9b1d32c4fd2f4781792" name="Management.php" /><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><dir name="Adminhtml"><dir name="Cache"><file hash="798cf7afa80e0a06be2b8c6cb2bef02b" name="Grid.php" /></dir></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="ce9fca4c273987759f284fe31c1597f5" name="Toolbar.php" /></dir></dir></dir><dir name="Product"><file hash="56ac2e90d0eed7eaadaf4517c1ad77ff" name="Compared.php" /><file hash="f72d0718ccd2895cbf4fc1cbc24bf90c" name="Viewed.php" /></dir><dir name="Core"><file hash="b34cad980a3e5da9860b21a7aa7a0b0f" name="Messages.php" /></dir><dir name="Poll"><file hash="bf9ca23a445776435e38e6c8be9976ea" name="ActivePoll.php" /></dir></dir></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies><authors><author><name>Chris Wells</name><user>nexcess_net</user><email>clwells@nexcess.net</email></author><author><name>Alex Headley</name><user>aheadley_nex</user><email>aheadley@nexcess.net</email></author></authors><date>2015-09-14</date><compatibile /><channel>community</channel><description>Turpentine is a Magento extension to improve Magento's compatibility with Varnish, a very-fast caching reverse-proxy. By default, Varnish doesn't cache requests with cookies and Magento sends the frontend cookie with every request causing a (near) zero hit-rate for Varnish's cache. Turpentine provides Varnish configuration files (VCLs) to work with Magento and modifies Magento's behaviour to significantly improve the cache hit rate.</description></package>
|