Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.113.2.8
diff -u -p -r1.113.2.8 install.php
--- install.php	25 Feb 2009 11:47:36 -0000	1.113.2.8
+++ install.php	25 Mar 2009 15:43:18 -0000
@@ -412,7 +412,7 @@ function install_settings_form_submit($f
  * 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);
 }
 
 /**
@@ -497,7 +497,7 @@ function install_select_profile_form(&$f
  * 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;
 }
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756.2.48
diff -u -p -r1.756.2.48 common.inc
--- includes/common.inc	25 Feb 2009 23:16:45 -0000	1.756.2.48
+++ includes/common.inc	25 Mar 2009 15:43:28 -0000
@@ -1997,7 +1997,7 @@ function _drupal_load_stylesheet($matche
  * 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);
 }
 
 /**
@@ -2371,7 +2371,7 @@ function drupal_build_js_cache($files, $
  * 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());
 }
 
Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.121.2.5
diff -u -p -r1.121.2.5 file.inc
--- includes/file.inc	20 Oct 2008 09:42:31 -0000	1.121.2.5
+++ includes/file.inc	25 Mar 2009 15:43:39 -0000
@@ -623,7 +623,7 @@ function file_validate_extensions($file,
 
   // Bypass validation for uid  = 1.
   if ($user->uid != 1) {
-    $regex = '/\.('. ereg_replace(' +', '|', preg_quote($extensions)) .')$/i';
+    $regex = '/\.('. str_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));
     }
@@ -892,7 +892,7 @@ function file_scan_directory($dir, $mask
           // 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";
           $basename = basename($file);
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.265.2.19
diff -u -p -r1.265.2.19 form.inc
--- includes/form.inc	22 Feb 2009 18:12:46 -0000	1.265.2.19
+++ includes/form.inc	25 Mar 2009 15:43:42 -0000
@@ -292,6 +292,10 @@ function form_get_cache($form_build_id, 
  */
 function drupal_execute($form_id, &$form_state) {
   $args = func_get_args();
+
+  // Make sure $form_state is passed around by reference.
+  $args[1] = &$form_state;
+  
   $form = call_user_func_array('drupal_retrieve_form', $args);
   $form['#post'] = $form_state['values'];
   drupal_prepare_form($form_id, $form, $form_state);
Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.56.2.4
diff -u -p -r1.56.2.4 install.inc
--- includes/install.inc	16 Feb 2009 10:25:02 -0000	1.56.2.4
+++ includes/install.inc	25 Mar 2009 15:43:42 -0000
@@ -252,7 +252,7 @@ function drupal_rewrite_settings($settin
 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;
 }
@@ -285,7 +285,7 @@ function drupal_verify_profile($profile,
 
   // 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;
   }
 
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.174.2.7
diff -u -p -r1.174.2.7 locale.inc
--- includes/locale.inc	6 Jan 2009 15:36:51 -0000	1.174.2.7
+++ includes/locale.inc	25 Mar 2009 15:43:49 -0000
@@ -2513,7 +2513,7 @@ function locale_batch_by_language($langc
     // 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;
   }
 
@@ -2545,7 +2545,7 @@ function locale_batch_by_component($comp
         // 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);
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.115.2.1
diff -u -p -r1.115.2.1 module.inc
--- includes/module.inc	16 Feb 2009 10:32:10 -0000	1.115.2.1
+++ includes/module.inc	25 Mar 2009 15:43:50 -0000
@@ -95,7 +95,7 @@ function module_list($refresh = FALSE, $
  */
 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');
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.415.2.19
diff -u -p -r1.415.2.19 theme.inc
--- includes/theme.inc	25 Feb 2009 21:02:16 -0000	1.415.2.19
+++ includes/theme.inc	25 Mar 2009 15:43:55 -0000
@@ -814,7 +814,7 @@ function drupal_find_theme_templates($ca
   $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);
Index: includes/unicode.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/unicode.inc,v
retrieving revision 1.29
diff -u -p -r1.29 unicode.inc
--- includes/unicode.inc	28 Dec 2007 12:02:50 -0000	1.29
+++ includes/unicode.inc	25 Mar 2009 15:44:03 -0000
@@ -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);
Index: modules/blogapi/blogapi.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v
retrieving revision 1.115.2.5
diff -u -p -r1.115.2.5 blogapi.module
--- modules/blogapi/blogapi.module	8 Oct 2008 20:12:17 -0000	1.115.2.5
+++ modules/blogapi/blogapi.module	25 Mar 2009 15:44:04 -0000
@@ -689,13 +689,14 @@ function blogapi_validate_user($username
  * For the blogger API, extract the node title from the contents field.
  */
 function blogapi_blogger_title(&$contents) {
-  if (eregi('<title>([^<]*)</title>', $contents, $title)) {
+  if (preg_match('/<title>(.*?)<\/title>/i', $contents, $title)) {
     $title = strip_tags($title[0]);
-    $contents = ereg_replace('<title>[^<]*</title>', '', $contents);
+    $contents = preg_replace('/<title>.*?<\/title>/i', '', $contents);
   }
   else {
     list($title, $contents) = explode("\n", $contents, 2);
   }
+
   return $title;
 }
 
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.63.2.7
diff -u -p -r1.63.2.7 system.admin.inc
--- modules/system/system.admin.inc	25 Feb 2009 11:38:41 -0000	1.63.2.7
+++ modules/system/system.admin.inc	25 Mar 2009 15:44:09 -0000
@@ -1971,7 +1971,7 @@ function theme_system_admin_by_module($m
  *   An array of requirements.
  * @ingroup themeable
  */
-function theme_status_report(&$requirements) {
+function theme_status_report($requirements) {
   $i = 0;
   $output = '<table class="system-status-report">';
   foreach ($requirements as $requirement) {
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.585.2.33
diff -u -p -r1.585.2.33 system.module
--- modules/system/system.module	25 Feb 2009 23:16:46 -0000	1.585.2.33
+++ modules/system/system.module	25 Mar 2009 15:44:13 -0000
@@ -835,9 +835,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();
 
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.197.2.4
diff -u -p -r1.197.2.4 upload.module
--- modules/upload/upload.module	12 Jan 2009 15:30:23 -0000	1.197.2.4
+++ modules/upload/upload.module	25 Mar 2009 15:44:15 -0000
@@ -513,7 +513,7 @@ function _upload_form($node) {
  *
  * @ingroup themeable
  */
-function theme_upload_form_current(&$form) {
+function theme_upload_form_current($form) {
   $header = array('', t('Delete'), t('List'), t('Description'), t('Weight'), t('Size'));
   drupal_add_tabledrag('upload-attachments', 'order', 'sibling', 'upload-weight');
 
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.892.2.12
diff -u -p -r1.892.2.12 user.module
--- modules/user/user.module	25 Feb 2009 13:57:04 -0000	1.892.2.12
+++ modules/user/user.module	25 Mar 2009 15:44:23 -0000
@@ -378,25 +378,36 @@ function user_save($account, $array = ar
  * Verify the syntax of the given name.
  */
 function user_validate_name($name) {
-  if (!strlen($name)) return t('You must enter a username.');
-  if (substr($name, 0, 1) == ' ') return t('The username cannot begin with a space.');
-  if (substr($name, -1) == ' ') return t('The username cannot end with a space.');
-  if (strpos($name, '  ') !== FALSE) return t('The username cannot contain multiple spaces in a row.');
-  if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.');
-  if (preg_match('/[\x{80}-\x{A0}'.          // Non-printable ISO-8859-1 + NBSP
-                   '\x{AD}'.                 // Soft-hyphen
-                   '\x{2000}-\x{200F}'.      // Various space characters
-                   '\x{2028}-\x{202F}'.      // Bidirectional text overrides
-                   '\x{205F}-\x{206F}'.      // Various text hinting characters
-                   '\x{FEFF}'.               // Byte order mark
-                   '\x{FF01}-\x{FF60}'.      // Full-width latin
-                   '\x{FFF9}-\x{FFFD}'.      // Replacement characters
-                   '\x{0}]/u',               // NULL byte
+  if (!$name) {
+    return t('You must enter a username.');
+  }
+  if (substr($name, 0, 1) == ' ') {
+    return t('The username cannot begin with a space.');
+  }
+  if (substr($name, -1) == ' ') {
+    return t('The username cannot end with a space.');
+  }
+  if (strpos($name, '  ') !== FALSE) {
+    return t('The username cannot contain multiple spaces in a row.');
+  }
+  if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)) {
+    return t('The username contains an illegal character.');
+  }
+  if (preg_match('/[\x{80}-\x{A0}' .         // Non-printable ISO-8859-1 + NBSP
+                   '\x{AD}' .                // Soft-hyphen
+                   '\x{2000}-\x{200F}' .     // Various space characters
+                   '\x{2028}-\x{202F}' .     // Bidirectional text overrides
+                   '\x{205F}-\x{206F}' .     // Various text hinting characters
+                   '\x{FEFF}' .              // Byte order mark
+                   '\x{FF01}-\x{FF60}' .     // Full-width latin
+                   '\x{FFF9}-\x{FFFD}' .     // Replacement characters
+                   '\x{0}-\x{1F}]/u',        // NULL byte and control characters
                    $name)) {
     return t('The username contains an illegal character.');
   }
-  if (strpos($name, '@') !== FALSE && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.');
-  if (strlen($name) > USERNAME_MAX_LENGTH) return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
+  if (drupal_strlen($name) > USERNAME_MAX_LENGTH) {
+    return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
+  }
 }
 
 function user_validate_mail($mail) {
@@ -1598,7 +1609,7 @@ function user_delete($edit, $uid) {
   db_query('DELETE FROM {authmap} WHERE uid = %d', $uid);
   $variables = array('%name' => $account->name, '%email' => '<'. $account->mail .'>');
   watchdog('user', 'Deleted user: %name %email.', $variables, WATCHDOG_NOTICE);
-  module_invoke_all('user', 'delete', $edit, $account);
+  user_module_invoke('delete', $edit, $account);
 }
 
 /**
@@ -1922,8 +1933,12 @@ function user_help($path, $arg) {
 function _user_categories($account) {
   $categories = array();
 
+  // only variables can be passed by refernce workaround
+  $null = NULL;
   foreach (module_list() as $module) {
-    if ($data = module_invoke($module, 'user', 'categories', NULL, $account, '')) {
+    $function = $module .'_user';
+    // we can't use neither module_invoke nor user_module_invoke because we need the return value and by reference
+    if (function_exists($function) && ($data = $function('categories', $null, $user, ''))) {
       $categories = array_merge($data, $categories);
     }
   }
@@ -2460,9 +2475,13 @@ function user_register_validate($form, &
  */
 function _user_forms(&$edit, $account, $category, $hook = 'form') {
   $groups = array();
+  // only variables can be passed by refernce workaround
+  $null = NULL;
   foreach (module_list() as $module) {
-    if ($data = module_invoke($module, 'user', $hook, $edit, $account, $category)) {
-      $groups = array_merge_recursive($data, $groups);
+    $function = $module .'_user';
+    // we can't use neither module_invoke nor user_module_invoke because we need the return value and by reference
+    if (function_exists($function) && ($data = $function($hook, $null, $user, ''))) {
+      $groups = array_merge($data, $categories);
     }
   }
   uasort($groups, '_user_sort');
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.11.2.1
diff -u -p -r1.11.2.1 user.pages.inc
--- modules/user/user.pages.inc	8 Oct 2008 20:12:18 -0000	1.11.2.1
+++ modules/user/user.pages.inc	25 Mar 2009 15:44:23 -0000
@@ -148,7 +148,9 @@ function user_logout() {
 
   // Destroy the current session:
   session_destroy();
-  module_invoke_all('user', 'logout', NULL, $user);
+  //// only variables can be passed by refernce workaround
+  $null = NULL;
+  user_module_invoke('logout', $null, $user);
 
   // Load the anonymous user
   $user = drupal_anonymous_user();
