From 89b4c55989eb0a1d2263de3a4a78c179f458cfee Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sat, 20 Sep 2008 03:49:24 +0000 Subject: #64967 follow-up by drewish: Replace ereg with preg in file_scan_directory(). --- includes/common.inc | 6 +++--- includes/file.inc | 4 ++-- includes/install.inc | 4 ++-- includes/locale.inc | 4 ++-- includes/module.inc | 2 +- includes/registry.inc | 2 +- includes/theme.inc | 2 +- install.php | 4 ++-- modules/simpletest/drupal_web_test_case.php | 2 +- modules/simpletest/simpletest.install | 4 ++-- modules/simpletest/simpletest.module | 2 +- modules/system/system.module | 4 ++-- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index bbd3b8f80..50be5bb71 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1952,7 +1952,7 @@ function _drupal_load_stylesheet($matches) { * Delete all cached CSS files. */ function drupal_clear_css_cache() { - file_scan_directory(file_create_path('css'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE); + file_scan_directory(file_create_path('css'), '/.*/', array('.', '..', 'CVS'), 'file_delete', TRUE); } /** @@ -2325,7 +2325,7 @@ function drupal_build_js_cache($files, $filename) { * Delete all cached JS files. */ function drupal_clear_js_cache() { - file_scan_directory(file_create_path('js'), '.*', array('.', '..', 'CVS'), 'file_delete', TRUE); + file_scan_directory(file_create_path('js'), '/.*/', array('.', '..', 'CVS'), 'file_delete', TRUE); variable_set('javascript_parsed', array()); } @@ -2651,7 +2651,7 @@ function drupal_cron_cleanup() { * version will be included. * * @param $mask - * The regular expression of the files to find. + * The preg_match() regular expression of the files to find. * @param $directory * The subdirectory name in which the files are found. For example, * 'modules' will search in both modules/ and diff --git a/includes/file.inc b/includes/file.inc index 7770b9244..e15aa3925 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -962,7 +962,7 @@ function file_download() { * @param $dir * The base directory for the scan, without trailing slash. * @param $mask - * The regular expression of the files to find. + * The preg_match() regular expression of the files to find. * @param $nomask * An array of files/directories to ignore. * @param $callback @@ -997,7 +997,7 @@ function file_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $ca // Give priority to files in this folder by merging them in after any subdirectory files. $files = array_merge(file_scan_directory("$dir/$file", $mask, $nomask, $callback, $recurse, $key, $min_depth, $depth + 1), $files); } - elseif ($depth >= $min_depth && ereg($mask, $file)) { + elseif ($depth >= $min_depth && preg_match($mask, $file)) { // Always use this match over anything already set in $files with the // same $$key. $filename = "$dir/$file"; diff --git a/includes/install.inc b/includes/install.inc index 3aea5b855..3bf434ebd 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -409,7 +409,7 @@ function drupal_rewrite_settings($settings = array(), $prefix = '') { function drupal_get_install_files($module_list = array()) { $installs = array(); foreach ($module_list as $module) { - $installs = array_merge($installs, drupal_system_listing($module . '.install$', 'modules')); + $installs = array_merge($installs, drupal_system_listing('/'. $module . '.install$/', 'modules')); } return $installs; } @@ -442,7 +442,7 @@ function drupal_verify_profile($profile, $locale) { // Get a list of modules that exist in Drupal's assorted subdirectories. $present_modules = array(); - foreach (drupal_system_listing('\.module$', 'modules', 'name', 0) as $present_module) { + foreach (drupal_system_listing('/\.module$/', 'modules', 'name', 0) as $present_module) { $present_modules[] = $present_module->name; } diff --git a/includes/locale.inc b/includes/locale.inc index 483497a6f..b06390265 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -2479,7 +2479,7 @@ function locale_batch_by_language($langcode, $finished = NULL, $skip = array()) // with names ending with $langcode.po. This allows for filenames // like node-module.de.po to let translators use small files and // be able to import in smaller chunks. - $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '(^|\.)' . $langcode . '\.po$', array('.', '..', 'CVS'), 0, FALSE)); + $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)' . $langcode . '\.po$/', array('.', '..', 'CVS'), 0, FALSE)); $components[] = $component->name; } @@ -2511,7 +2511,7 @@ function locale_batch_by_component($components, $finished = '_locale_batch_syste // as $langcode.po or with names ending with $langcode.po. This allows // for filenames like node-module.de.po to let translators use small // files and be able to import in smaller chunks. - $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '(^|\.)(' . $language_list . ')\.po$', array('.', '..', 'CVS'), 0, FALSE)); + $files = array_merge($files, file_scan_directory(dirname($component->filename) . '/translations', '/(^|\.)(' . $language_list . ')\.po$/', array('.', '..', 'CVS'), 0, FALSE)); } } return _locale_batch_build($files, $finished); diff --git a/includes/module.inc b/includes/module.inc index a1aa899b6..2a131d81f 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -80,7 +80,7 @@ function module_list($refresh = FALSE, $bootstrap = TRUE, $sort = FALSE, $fixed_ */ function module_rebuild_cache() { // Get current list of modules - $files = drupal_system_listing('\.module$', 'modules', 'name', 0); + $files = drupal_system_listing('/\.module$/', 'modules', 'name', 0); // Extract current files from database. system_get_files_database($files, 'module'); diff --git a/includes/registry.inc b/includes/registry.inc index 636687136..e306c8487 100644 --- a/includes/registry.inc +++ b/includes/registry.inc @@ -49,7 +49,7 @@ function _registry_rebuild() { } } } - foreach (file_scan_directory('includes', '\.inc$') as $filename => $file) { + foreach (file_scan_directory('includes', '/\.inc$/') as $filename => $file) { $files["./$filename"] = array(); } diff --git a/includes/theme.inc b/includes/theme.inc index 4121937e4..2ad9f2e6e 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -790,7 +790,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array(); // Escape the periods in the extension. - $regex = str_replace('.', '\.', $extension) . '$'; + $regex = '/'. str_replace('.', '\.', $extension) . '$/'; // Because drupal_system_listing works the way it does, we check for real // templates separately from checking for patterns. $files = drupal_system_listing($regex, $path, 'name', 0); diff --git a/install.php b/install.php index 6c01f1040..faf909a6c 100644 --- a/install.php +++ b/install.php @@ -401,7 +401,7 @@ function install_settings_form_submit($form, &$form_state) { * Find all .profile files. */ function install_find_profiles() { - return file_scan_directory('./profiles', '\.profile$', array('.', '..', 'CVS'), 0, TRUE, 'name', 0); + return file_scan_directory('./profiles', '/\.profile$/', array('.', '..', 'CVS'), 0, TRUE, 'name', 0); } /** @@ -487,7 +487,7 @@ function install_select_profile_form(&$form_state, $profile_files) { * Find all .po files for the current profile. */ function install_find_locales($profilename) { - $locales = file_scan_directory('./profiles/' . $profilename . '/translations', '\.po$', array('.', '..', 'CVS'), 0, FALSE); + $locales = file_scan_directory('./profiles/' . $profilename . '/translations', '/\.po$/', array('.', '..', 'CVS'), 0, FALSE); array_unshift($locales, (object) array('name' => 'en')); return $locales; } diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 5bfba7c62..10f1e1390 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -467,7 +467,7 @@ class DrupalWebTestCase { if (in_array($type, array('binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'))) { // Use original file directory instead of one created during setUp(). $path = $this->original_file_directory . '/simpletest'; - $files = file_scan_directory($path, $type . '\-.*'); + $files = file_scan_directory($path, '/' . $type . '\-.*/'); // If size is set then remove any files that are not of that size. if ($size !== NULL) { diff --git a/modules/simpletest/simpletest.install b/modules/simpletest/simpletest.install index c6d5c34c7..4d549399b 100644 --- a/modules/simpletest/simpletest.install +++ b/modules/simpletest/simpletest.install @@ -28,10 +28,10 @@ function simpletest_install() { } // Copy other test files for consistency. - $files = file_scan_directory($path, '(html|image|javascript|php|sql)-.*'); + $files = file_scan_directory($path, '/(html|image|javascript|php|sql)-.*/'); if (count($files) == 0) { $original = drupal_get_path('module', 'simpletest') . '/files'; - $files = file_scan_directory($original, '(html|image|javascript|php|sql)-.*'); + $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/'); foreach ($files as $file) { file_copy($file->filename, $path . '/' . $file->basename); } diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module index abeb8c14b..138045f83 100644 --- a/modules/simpletest/simpletest.module +++ b/modules/simpletest/simpletest.module @@ -435,7 +435,7 @@ function simpletest_get_all_tests() { $tests_directory = $module_path . '/tests'; if (is_dir($tests_directory)) { - foreach (file_scan_directory($tests_directory, '\.test$') as $file) { + foreach (file_scan_directory($tests_directory, '/\.test$/') as $file) { $files[] = $file->filename; } } diff --git a/modules/system/system.module b/modules/system/system.module index 30bc90980..ef1735e1f 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1003,9 +1003,9 @@ function _system_theme_data() { if (empty($themes_info)) { // Find themes - $themes = drupal_system_listing('\.info$', 'themes'); + $themes = drupal_system_listing('/\.info$/', 'themes'); // Find theme engines - $engines = drupal_system_listing('\.engine$', 'themes/engines'); + $engines = drupal_system_listing('/\.engine$/', 'themes/engines'); $defaults = system_theme_default(); -- cgit v1.2.3