diff --git a/includes/file.inc b/includes/file.inc
index 24248ad8460c7856ccea2c4cd2ebcebcac234417..38c4999ff1b0ddccffb89bb8b1f8227bdfed1a63 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -1100,7 +1100,7 @@ function file_validate_size($file, $file_limit = 0, $user_limit = 0) {
  *
  * @see hook_file_validate()
  */
-function file_validate_is_image(&$file) {
+function file_validate_is_image($file) {
   $errors = array();
 
   $info = image_get_info($file->filepath);
@@ -1135,7 +1135,7 @@ function file_validate_is_image(&$file) {
  *
  * @see hook_file_validate()
  */
-function file_validate_image_resolution(&$file, $maximum_dimensions = 0, $minimum_dimensions = 0) {
+function file_validate_image_resolution($file, $maximum_dimensions = 0, $minimum_dimensions = 0) {
   $errors = array();
 
   // Check first that the file is an image.
diff --git a/includes/form.inc b/includes/form.inc
index af42e8e272225a350b0ee791ad6663a79d42a2cf..7030463027e71f9f6ddf9c8196de4c2af96cca20 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -291,6 +291,10 @@ function form_set_cache($form_build_id, $form, $form_state) {
  */
 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);
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 951ac3c95247303bc7e489b5689d6c4c01727e96..da9ea6f35ea3d2799c9d1c2a61bdebbfbbe4d888 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -705,7 +705,7 @@ function comment_nodeapi_rss_item($node) {
 /**
  * Implementation of hook_user_cancel().
  */
-function comment_user_cancel(&$edit, &$account, $method) {
+function comment_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_block_unpublish':
       db_update('comment')->fields(array('status' => 0))->condition('uid', $account->uid)->execute();
diff --git a/modules/dblog/dblog.module b/modules/dblog/dblog.module
index 03ab8c46d8bc38287a1910c41e0eeb415bfb4a2c..44f029ed9f1cf80aad2f76645a77d6fa4b5d3e41 100644
--- a/modules/dblog/dblog.module
+++ b/modules/dblog/dblog.module
@@ -104,7 +104,7 @@ function dblog_cron() {
 /**
  * Implementation of hook_user_cancel().
  */
-function dblog_user_cancel(&$edit, &$account, $method) {
+function dblog_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_reassign':
       db_update('watchdog')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute();
diff --git a/modules/node/node.module b/modules/node/node.module
index 63ac460ad54de538be742cae874a53dbc4997d3c..3936359ade75ace8ca902b1c421750ef8d8a9ebd 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1481,7 +1481,7 @@ function node_ranking() {
 /**
  * Implementation of hook_user_cancel().
  */
-function node_user_cancel(&$edit, &$account, $method) {
+function node_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_block_unpublish':
       // Unpublish nodes (current revisions).
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 101528975ebbc4b4f86a01d280f733867f4114ad..86ceee59da9731eaacd74c24105eafc9a594b7ad 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -817,7 +817,7 @@ function poll_cancel($form, &$form_state) {
 /**
  * Implementation of hook_user_cancel().
  */
-function poll_user_cancel(&$edit, &$account, $method) {
+function poll_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_reassign':
       db_update('poll_vote')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute();
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 9d11b0a9dfa76f6c41ff931c4c1d5d4ccf4a1202..e915a97ad1ff609423f453337c77606345270fba 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -254,7 +254,7 @@ function profile_user_validate(&$edit, &$user, $category = NULL) {
 /**
  * Implementation of hook_user_categories().
  */
-function profile_user_categories(&$edit, &$user, $category = NULL) {
+function profile_user_categories($edit, $user, $category = NULL) {
   return profile_categories();
 }
 
diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test
index 3c47265264a8b8d53a181cb54a8783e689dce369..d3934988d500abfe2779fcd466e18967cf04d8f8 100644
--- a/modules/simpletest/simpletest.test
+++ b/modules/simpletest/simpletest.test
@@ -147,7 +147,9 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
     $this->assertAssertion('This is nothing.', 'Other', 'Pass', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
 
     // Check that errors that occur inside PHP internal functions are correctly reported.
-    $this->assertAssertion('The second argument should be either an array or an object', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
+    // The exact error message differs between PHP versions so we check only
+    // the function name 'array_key_exists'.
+    $this->assertAssertion('array_key_exists', 'Warning', 'Fail', 'simpletest.test', 'SimpleTestFunctionalTest->stubTest()');
 
     $this->test_ids[] = $test_id = $this->getTestIdFromResults();
     $this->assertTrue($test_id, t('Found test ID in results.'));
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 7a8d5b4a26a7856adb215dba3fb019a7a7d38f9e..4bb696098909c21e3e086e43c74a6058f4729863 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -186,7 +186,7 @@ function statistics_menu() {
 /**
  * Implementation of hook_user_cancel().
  */
-function statistics_user_cancel(&$edit, &$account, $method) {
+function statistics_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_reassign':
       db_update('accesslog')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute();
diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index afe65919cacd6e414be1daeb88514a9440712fb7..703de2d0127c8bf6c96bb9bfdcc1621b23fe90b8 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc
@@ -2046,7 +2046,7 @@ function theme_system_admin_by_module($menu_items) {
  *   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) {
diff --git a/modules/trigger/trigger.module b/modules/trigger/trigger.module
index bc78d23231e45c357c7552674e497775bac490e0..872ebf4eafe83d83fbc268331215c465c476359c 100644
--- a/modules/trigger/trigger.module
+++ b/modules/trigger/trigger.module
@@ -422,7 +422,7 @@ function trigger_user_login(&$edit, &$account, $category) {
 /**
  * Implementation of hook_user_logout().
  */
-function trigger_user_logout(&$edit, &$account) {
+function trigger_user_logout($edit, $account) {
   _trigger_user('logout', $edit, $account);
 }
 
@@ -443,7 +443,7 @@ function trigger_user_update(&$edit, &$account, $category) {
 /**
  * Implementation of hook_user_cancel().
  */
-function trigger_user_cancel(&$edit, &$account, $method) {
+function trigger_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_reassign':
     case 'user_cancel_delete':
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 71e8e3a1692853564e2aa63003566dff8b2981a9..0971c978bb8ea19c9bfb19a460ec9fbb4853645d 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -282,7 +282,7 @@ function upload_file_load($files) {
 /**
  * Implementation of hook_file_references().
  */
-function upload_file_references(&$file) {
+function upload_file_references($file) {
   // If upload.module is still using a file, do not let other modules delete it.
   $count = db_query('SELECT COUNT(*) FROM {upload} WHERE fid = :fid', array(':fid' => $file->fid))->fetchField();
   if ($count) {
@@ -294,7 +294,7 @@ function upload_file_references(&$file) {
 /**
  * Implementation of hook_file_delete().
  */
-function upload_file_delete(&$file) {
+function upload_file_delete($file) {
   // Delete all information associated with the file.
   db_delete('upload')->condition('fid', $file->fid)->execute();
 }
@@ -604,7 +604,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');
 
diff --git a/modules/user/user.api.php b/modules/user/user.api.php
index 7398bb0eee4dc8e29401fcd623485dbaafad696e..4d7feef77522338e14504d2ce96aa28db0f98d15 100644
--- a/modules/user/user.api.php
+++ b/modules/user/user.api.php
@@ -94,9 +94,9 @@ function hook_user($op, &$edit, &$account, $category = NULL) {
  *
  * Expensive operations should be added to the global batch with batch_set().
  *
- * @param &$edit
+ * @param $edit
  *   The array of form values submitted by the user.
- * @param &$account
+ * @param $account
  *   The user object on which the operation is being performed.
  * @param $method
  *   The account cancellation method.
@@ -105,7 +105,7 @@ function hook_user($op, &$edit, &$account, $category = NULL) {
  * @see hook_user_cancel_methods_alter()
  * @see user_cancel()
  */
-function hook_user_cancel(&$edit, &$account, $method) {
+function hook_user_cancel($edit, $account, $method) {
   switch ($method) {
     case 'user_cancel_block_unpublish':
       // Unpublish nodes (current revisions).
diff --git a/modules/user/user.module b/modules/user/user.module
index d2e7207587a9415e234626c23d2f9a99009b6478..97f1084135f1cfc853b275f4a47bfe6cd69eaeb6 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -790,7 +790,7 @@ function user_user_submit(&$edit, &$account, $category = NULL) {
 /**
  * Implementation of hook_user_categories.
  */
-function user_user_categories(&$edit, &$account, $category = NULL) {
+function user_user_categories($edit, $account, $category = NULL) {
     return array(array('name' => 'account', 'title' => t('Account settings'), 'weight' => 1));
 }