From ff246ebcc9b67f7a47ad52529ae81a60a3269305 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Tue, 13 Oct 2015 01:01:46 -0400 Subject: Issue #2146643 by quicksketch: Speed up drupal_parse_info_format() 3x and reduce memory 95% --- CHANGELOG.txt | 2 ++ includes/common.inc | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index f23b9c993..ed1dd62bd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,8 @@ Drupal 7.40, xxxx-xx-xx (development version) ----------------------- +- Made Drupal's code for parsing .info files run much faster and use much less + memory. - Prevented drupal_http_request() from returning an error when it receives a 201 through 206 HTTP status code. - Added support for autoloading traits via the registry on sites running PHP diff --git a/includes/common.inc b/includes/common.inc index ab763bad7..e5e8150dc 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -7468,7 +7468,6 @@ function drupal_parse_info_file($filename) { */ function drupal_parse_info_format($data) { $info = array(); - $constants = get_defined_constants(); if (preg_match_all(' @^\s* # Start at the beginning of a line, ignoring leading whitespace @@ -7508,8 +7507,8 @@ function drupal_parse_info_format($data) { } // Handle PHP constants. - if (isset($constants[$value])) { - $value = $constants[$value]; + if (preg_match('/^\w+$/i', $value) && defined($value)) { + $value = constant($value); } // Insert actual value. -- cgit v1.2.3