From dbc8204ab1e8a29f087260ba05c0796c77527636 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Fri, 18 Sep 2015 05:10:13 +0000 Subject: [PATCH] try and support older versions of PHP (e.g 5.3) which do not support closures etc git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1798 a1433add-5e2c-0410-b055-b7f2511e0802 --- upgrade.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/upgrade.php b/upgrade.php index 4f53fd99..a071ce20 100644 --- a/upgrade.php +++ b/upgrade.php @@ -71,6 +71,9 @@ function _db_field_exists($table, $field) { return _mysql_field_exists($table, $field); } } +function _upgrade_filter_function($name) { + return preg_match('/upgrade_[\d]+(_mysql|_pgsql)?$/', $name) == 1; +} function _db_add_field($table, $field, $fieldtype, $after) { global $CONF; @@ -141,7 +144,8 @@ function _do_upgrade($current_version) { $target_version = 0; // Rather than being bound to an svn revision number, just look for the largest function name that matches upgrade_\d+... // $target_version = preg_replace('/[^0-9]/', '', '$Revision$'); - $our_upgrade_functions = array_filter(get_defined_functions()['user'], function($name) { return preg_match('/upgrade_[\d]+(_mysql|_pgsql)?$/', $name) == 1; } ); + $funclist = get_defined_functions(); + $our_upgrade_functions = array_filter($funclist['user'], '_upgrade_filter_function'); foreach($our_upgrade_functions as $function_name) { $bits = explode("_", $function_name); $function_number = $bits[1];