From 8861a546b8ca766fff447081e90c9a67a4a822f4 Mon Sep 17 00:00:00 2001 From: xjm Date: Sat, 20 Oct 2018 02:14:35 -0500 Subject: [PATCH] Issue #2575105 by alexpott: hotfix for PHP 5 test failures in ShutdownFunctionsTest --- core/includes/bootstrap.inc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 45c9490713b..ebcd2176a73 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1033,8 +1033,12 @@ function _drupal_shutdown_function() { chdir(DRUPAL_ROOT); try { - foreach ($callbacks as &$callback) { + reset($callbacks); + // Do not use foreach() here because it is possible that the callback will + // add to the $callbacks array via drupal_register_shutdown_function(). + while ($callback = current($callbacks)) { call_user_func_array($callback['callback'], $callback['arguments']); + next($callbacks); } } // PHP 7 introduces Throwable, which covers both Error and