From 2b0766503392aaf91837b64ca6a0a3c6d2f035ce Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 5 Sep 2008 09:25:52 +0000 Subject: - Patch #64967 by Arancaytar, meba: ereg -> preg for performance reasons and future compatilbility. PHP6 is rumoured to drop ereg support. --- includes/database/select.inc | 4 +++- includes/file.inc | 2 +- includes/unicode.inc | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/database/select.inc b/includes/database/select.inc index 3d1074773..e24b54cc2 100644 --- a/includes/database/select.inc +++ b/includes/database/select.inc @@ -670,9 +670,11 @@ class SelectQuery extends Query implements QueryConditionInterface, QueryAlterab // ORDER BY if ($this->order) { $query .= "\nORDER BY "; + $fields = array(); foreach ($this->order as $field => $direction) { - $query .= $field . ' ' . $direction . ' '; + $fields[] = $field . ' ' . $direction; } + $query .= implode(', ', $fields); } // RANGE is database specific, so we can't do it here. diff --git a/includes/file.inc b/includes/file.inc index 68fa2c23b..1be451823 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -658,7 +658,7 @@ function file_validate_extensions($file, $extensions) { // Bypass validation for uid = 1. if ($user->uid != 1) { - $regex = '/\.(' . ereg_replace(' +', '|', preg_quote($extensions)) . ')$/i'; + $regex = '/\.(' . preg_replace('/ +/', '|', preg_quote($extensions)) . ')$/i'; if (!preg_match($regex, $file->filename)) { $errors[] = t('Only files with the following extensions are allowed: %files-allowed.', array('%files-allowed' => $extensions)); } diff --git a/includes/unicode.inc b/includes/unicode.inc index 93a522d09..b01e3bcfd 100644 --- a/includes/unicode.inc +++ b/includes/unicode.inc @@ -135,7 +135,7 @@ function drupal_xml_parser_create(&$data) { } // Check for an encoding declaration in the XML prolog if no BOM was found. - if (!$bom && ereg('^<\?xml[^>]+encoding="([^"]+)"', $data, $match)) { + if (!$bom && preg_match('/^<\?xml[^>]+encoding="(.+?)"/', $data, $match)) { $encoding = $match[1]; } @@ -145,7 +145,7 @@ function drupal_xml_parser_create(&$data) { $out = drupal_convert_to_utf8($data, $encoding); if ($out !== FALSE) { $encoding = 'utf-8'; - $data = ereg_replace('^(<\?xml[^>]+encoding)="([^"]+)"', '\\1="utf-8"', $out); + $data = preg_replace('/^(<\?xml[^>]+encoding)="(.+?)"/', '\\1="utf-8"', $out); } else { watchdog('php', 'Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding), WATCHDOG_WARNING); -- cgit v1.2.3