since we recently decided to lift our minimum requirements for XH 1.7 to PHP 5.3, I like to suggest to replace all create_functions() in the core and the standard plugins with anonymous functions for better comprehensibility and to avoid the quoting hell.
While preparing a respective patch, I've noticed a bug in meta_tags. Fixing this bug already gets rid of a create_function(), so we're left with only two create_function() calls.
I suggest the following patch:
Code: Select all
Index: cmsimple/classes/Mailform.php
===================================================================
--- cmsimple/classes/Mailform.php (revision 1490)
+++ cmsimple/classes/Mailform.php (working copy)
@@ -404,8 +404,9 @@
$text = '';
}
} while ($text != '');
- $body = 'return \'=?UTF-8?B?\' . base64_encode($l) . \'?=\';';
- $func = create_function('$l', $body);
+ $func = function ($line) {
+ return '=?UTF-8?B?' . base64_encode($line) . '?=';
+ };
return implode($this->_linebreak . ' ', array_map($func, $lines));
}
}
Index: cmsimple/functions.php
===================================================================
--- cmsimple/functions.php (revision 1490)
+++ cmsimple/functions.php (working copy)
@@ -2849,7 +2849,12 @@
*/
function XH_highlightSearchWords($words, $text)
{
- usort($words, create_function('$a, $b', 'return strlen($b) - strlen($a);'));
+ usort(
+ $words,
+ function ($a, $b) {
+ return strlen($b) - strlen($a);
+ }
+ );
$patterns = array();
foreach ($words as $word) {
$patterns[] = '/' . preg_quote($word, '/') . '(?![^<]*>)/isuU';
Index: plugins/meta_tags/Metatags_view.php
===================================================================
--- plugins/meta_tags/Metatags_view.php (revision 1490)
+++ plugins/meta_tags/Metatags_view.php (working copy)
@@ -40,9 +40,6 @@
{
global $sn, $su, $plugin_tx, $pth, $onload, $bjs;
- $func = create_function('&$data', '$data=str_replace("\"", """, $data);');
- array_walk($page, $func);
-
$lang = $plugin_tx['meta_tags'];
$my_fields = array('title', 'description', 'keywords', 'robots');