Skip to content

Commit 4c0470f

Browse files
committed
replaced create_function calls with anonymous functions, fixes nexcess#1518
1 parent 96bbdda commit 4c0470f

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

app/code/community/Nexcessnet/Turpentine/Helper/Esi.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,9 @@ protected function _loadEsiCacheClearEvents() {
405405
$events = $layoutXml->xpath(
406406
'//action[@method=\'setEsiOptions\']/params/flush_events/*' );
407407
if ($events) {
408-
$events = array_unique(array_map(
409-
create_function('$e',
410-
'return (string)$e->getName();'),
411-
$events ));
408+
$events = array_unique(array_map(function ($e) {
409+
return (string)$e->getName();
410+
}, $events));
412411
} else {
413412
$events = array();
414413
}

app/code/community/Nexcessnet/Turpentine/Model/Observer/Ban.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ public function banProductReview($eventObject) {
308308

309309
$products = $productCollection->addEntityFilter((int) $review->getEntityPkValue())->getItems();
310310

311-
$productIds = array_unique(array_map(
312-
create_function('$p', 'return $p->getEntityId();'),
313-
$products ));
311+
$productIds = array_unique(array_map(function ($p) {
312+
return $p->getEntityId();
313+
}, $products));
314314
$patterns[] = sprintf('/review/product/list/id/(?:%s)/category/',
315315
implode('|', array_unique($productIds)));
316316
$patterns[] = sprintf('/review/product/view/id/%d/',

app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php

+12-8
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,9 @@ protected function _getCustomTemplateFilename() {
164164
* @return string
165165
*/
166166
protected function _formatTemplate($template, array $vars) {
167-
$needles = array_map(create_function('$k', 'return "{{".$k."}}";'),
168-
array_keys($vars));
167+
$needles = array_map(function ($k) {
168+
return '{{' . $k . '}}';
169+
}, array_keys($vars));
169170
$replacements = array_values($vars);
170171
// do replacements, then delete unused template vars
171172
return preg_replace('~{{[^}]+}}~', '',
@@ -269,9 +270,9 @@ protected function _vcl_sub_allowed_hosts_regex() {
269270
*/
270271
public function getBaseUrlPathRegex() {
271272
$pattern = '^(%s)(?:(?:index|litespeed)\\.php/)?';
272-
return sprintf($pattern, implode('|',
273-
array_map(create_function('$x', 'return preg_quote($x,"|");'),
274-
$this->_getBaseUrlPaths())));
273+
return sprintf($pattern, implode('|', array_map(function ($x) {
274+
return preg_quote($x, '|');
275+
}, $this->_getBaseUrlPaths())));
275276
}
276277

277278
/**
@@ -294,8 +295,9 @@ protected function _getBaseUrlPaths() {
294295
}
295296
}
296297
$paths = array_unique($paths);
297-
usort($paths, create_function('$a, $b',
298-
'return strlen( $b ) - strlen( $a );'));
298+
usort($paths, function ($a, $b) {
299+
return strlen($b) - strlen($a);
300+
});
299301
return array_values($paths);
300302
}
301303

@@ -794,7 +796,9 @@ protected function _vcl_acl($name, array $hosts) {
794796
{{hosts}}
795797
}
796798
EOS;
797-
$fmtHost = create_function('$h', 'return sprintf(\'"%s";\',$h);');
799+
$fmtHost = function ($h) {
800+
return sprintf('"%s";', $h);
801+
};
798802
$vars = array(
799803
'name' => $name,
800804
'hosts' => implode("\n ", array_map($fmtHost, $hosts)),

util/varnishadm.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ class Turpentine_Shell_Varnishadm extends Mage_Shell_Abstract {
2929
* @return array
3030
*/
3131
protected function _parseArgs() {
32-
$this->_args = array_slice(
33-
array_filter($_SERVER['argv'],
34-
create_function('$e',
35-
'return $e != \'--\';')),
36-
1 );
32+
$this->_args = array_slice(array_filter($_SERVER['argv'], function ($e) {
33+
return $e != '--';
34+
}), 1);
3735
return $this;
3836
}
3937

0 commit comments

Comments
 (0)