From 48d1c2b809652af6476337f4fc16fdd3fecf1482 Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Tue, 17 Apr 2012 18:41:28 +0000
Subject: [PATCH 1/8] Remove extra space around concatenation in authorize.inc

---
 core/includes/authorize.inc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/core/includes/authorize.inc b/core/includes/authorize.inc
index cf55624..ce0fc1a 100644
--- a/core/includes/authorize.inc
+++ b/core/includes/authorize.inc
@@ -216,7 +216,7 @@ function authorize_filetransfer_form_validate($form, &$form_state) {
       // The format of this error message is similar to that used on the
       // database connection form in the installer.
       form_set_error('connection_settings', t('Failed to connect to the server. The server reports the following message: !message For more help installing or updating code on your server, see the <a href="@handbook_url">handbook</a>.', array(
-        '!message' => '<p class="error">' . $e->getMessage()  . '</p>',
+        '!message' => '<p class="error">' . $e->getMessage() . '</p>',
         '@handbook_url' => 'http://drupal.org/documentation/install/modules-themes',
       )));
     }
-- 
1.7.5.4


From 72e4cc77d60b5142cdff1c7caf77a7b67eec9376 Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Tue, 17 Apr 2012 18:42:04 +0000
Subject: [PATCH 2/8] Add space around concatenation in common.inc

---
 core/includes/common.inc |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 32f5a7e..7862f2d 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -3734,12 +3734,12 @@ function _drupal_load_stylesheet($matches) {
   $directory = dirname($filename);
   // If the file is in the current directory, make sure '.' doesn't appear in
   // the url() path.
-  $directory = $directory == '.' ? '' : $directory .'/';
+  $directory = $directory == '.' ? '' : $directory . '/';
 
   // Alter all internal url() paths. Leave external paths alone. We don't need
   // to normalize absolute paths here (i.e. remove folder/... segments) because
   // that will be done later.
-  return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+)/i', 'url(\1'. $directory, $file);
+  return preg_replace('/url\(\s*([\'"]?)(?![a-z]+:|\/+)/i', 'url(\1' . $directory, $file);
 }
 
 /**
-- 
1.7.5.4


From 1ae8062f579aa4cc9da8dd04b90250095af38ab7 Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Tue, 17 Apr 2012 18:43:04 +0000
Subject: [PATCH 3/8] Various coding standards changes in common.inc

---
 core/includes/config.inc |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/core/includes/config.inc b/core/includes/config.inc
index b438977..75b68bf 100644
--- a/core/includes/config.inc
+++ b/core/includes/config.inc
@@ -168,18 +168,18 @@ function config_decode($data) {
  */
 function config_xml_to_array($data) {
   $out = array();
-  $xmlObject = simplexml_load_string($data);
+  $xml_object = simplexml_load_string($data);
 
-  if (is_object($xmlObject)) {
-    $attributes = (array) $xmlObject->attributes();
+  if (is_object($xml_object)) {
+    $attributes = (array) $xml_object->attributes();
     if (isset($attributes['@attributes'])) {
       $out['#attributes'] = $attributes['@attributes'];
     }
   }
-  if (trim((string) $xmlObject)) {
-    return trim((string) $xmlObject);
+  if (trim((string) $xml_object)) {
+    return trim((string) $xml_object);
   }
-  foreach ($xmlObject as $index => $content) {
+  foreach ($xml_object as $index => $content) {
     if (is_object($content)) {
       $out[$index] = config_xml_to_array($content);
     }
@@ -208,8 +208,8 @@ function config_encode($data) {
 
   // Pretty print the result.
   $dom = new DOMDocument('1.0');
-  $dom->preserveWhiteSpace = false;
-  $dom->formatOutput = true;
+  $dom->preserveWhiteSpace = FALSE;
+  $dom->formatOutput = TRUE;
   $dom->loadXML($xml_object->asXML());
 
   return $dom->saveXML();
@@ -228,7 +228,7 @@ function config_encode($data) {
 function config_array_to_xml($array, &$xml_object) {
   foreach ($array as $key => $value) {
     if (is_array($value)) {
-      if (!is_numeric($key)){
+      if (!is_numeric($key)) {
         $subnode = $xml_object->addChild("$key");
         config_array_to_xml($value, $subnode);
       }
-- 
1.7.5.4


From 9f7931290f7de1e86e45cdb4fa02db01e3add5ae Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Tue, 17 Apr 2012 23:01:29 +0000
Subject: [PATCH 4/8] Fix code style in actions.inc

---
 core/includes/actions.inc |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/core/includes/actions.inc b/core/includes/actions.inc
index 75cda42..6ad3f88 100644
--- a/core/includes/actions.inc
+++ b/core/includes/actions.inc
@@ -339,7 +339,7 @@ function actions_synchronize($delete_orphans = FALSE) {
  *   The ID of the action.
  */
 function actions_save($function, $type, $params, $label, $aid = NULL) {
-  // aid is the callback for singleton actions so we need to keep a separate
+  // $aid is the callback for singleton actions so we need to keep a separate
   // table for numeric aids.
   if (!$aid) {
     $aid = db_next_id();
@@ -384,4 +384,3 @@ function actions_delete($aid) {
     ->execute();
   module_invoke_all('actions_delete', $aid);
 }
-
-- 
1.7.5.4


From 77824b742bc797af65ad2b7bc71094c88011cbd1 Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Tue, 17 Apr 2012 23:02:04 +0000
Subject: [PATCH 5/8] Remove extra newline after case statement in
 authorize.inc

---
 core/includes/authorize.inc |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/core/includes/authorize.inc b/core/includes/authorize.inc
index ce0fc1a..6de5641 100644
--- a/core/includes/authorize.inc
+++ b/core/includes/authorize.inc
@@ -233,7 +233,6 @@ function authorize_filetransfer_form_submit($form, &$form_state) {
   global $base_url;
   switch ($form_state['triggering_element']['#name']) {
     case 'process_updates':
-
       // Save the connection settings to the DB.
       $filetransfer_backend = $form_state['values']['connection_settings']['authorize_filetransfer_default'];
 
-- 
1.7.5.4


From 57dea483f67031e59a6ecacbc54d5007184eba5a Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Tue, 17 Apr 2012 23:02:49 +0000
Subject: [PATCH 6/8] Fix comments, indentation and other code style violation
 in bootstrap.inc

---
 core/includes/bootstrap.inc |  112 ++++++++++++++++++++++--------------------
 1 files changed, 59 insertions(+), 53 deletions(-)

diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index f50dd39..3e57891 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -439,7 +439,7 @@ function find_conf_path($http_host, $script_name, $require_settings = TRUE) {
   $sites = array();
   if (file_exists(DRUPAL_ROOT . '/' . $confdir . '/sites.php')) {
     // This will overwrite $sites with the desired mappings.
-    include(DRUPAL_ROOT . '/' . $confdir . '/sites.php');
+    include DRUPAL_ROOT . '/' . $confdir . '/sites.php';
   }
 
   $uri = explode('/', $script_name);
@@ -598,7 +598,7 @@ function drupal_valid_http_host($host) {
 function drupal_settings_initialize() {
   global $base_url, $base_path, $base_root;
 
-  // Export the following settings.php variables to the global namespace
+  // Export the following settings.php variables to the global namespace.
   global $databases, $cookie_domain, $conf, $installed_profile, $update_free_access, $db_url, $db_prefix, $drupal_hash_salt, $is_https, $base_secure_url, $base_insecure_url, $config_directory_name, $config_signature_key;
   $conf = array();
 
@@ -619,7 +619,7 @@ function drupal_settings_initialize() {
     $base_root = substr($base_url, 0, strlen($base_url) - strlen($parts['path']));
   }
   else {
-    // Create base URL
+    // Create base URL.
     $http_protocol = $is_https ? 'https' : 'http';
     $base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
 
@@ -654,7 +654,7 @@ function drupal_settings_initialize() {
   else {
     // Otherwise use $base_url as session name, without the protocol
     // to use the same session identifiers across http and https.
-    list( , $session_name) = explode('://', $base_url, 2);
+    list(, $session_name) = explode('://', $base_url, 2);
     // HTTP_HOST can be modified by a visitor, but we already sanitized it
     // in drupal_settings_initialize().
     if (!empty($_SERVER['HTTP_HOST'])) {
@@ -669,15 +669,16 @@ function drupal_settings_initialize() {
     }
   }
   // Per RFC 2109, cookie domains must contain at least one dot other than the
-  // first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
+  // first. For hosts such as 'localhost' or IP Addresses we don't set a cookie
+  // domain.
   if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
     ini_set('session.cookie_domain', $cookie_domain);
   }
   // To prevent session cookies from being hijacked, a user can configure the
   // SSL version of their website to only transfer session cookies via SSL by
   // using PHP's session.cookie_secure setting. The browser will then use two
-  // separate session cookies for the HTTPS and HTTP versions of the site. So we
-  // must use different session identifiers for HTTPS and HTTP to prevent a
+  // separate session cookies for the HTTPS and HTTP versions of the site. So
+  // we must use different session identifiers for HTTPS and HTTP to prevent a
   // cookie collision.
   if ($is_https) {
     ini_set('session.cookie_secure', TRUE);
@@ -732,9 +733,6 @@ function drupal_get_filename($type, $name, $filename = NULL) {
   if (!empty($filename) && file_exists($filename)) {
     $files[$type][$name] = $filename;
   }
-  elseif (isset($files[$type][$name])) {
-    // nothing
-  }
   // Verify that we have an active database connection, before querying
   // the database. This is required because this function is called both
   // before we have a database connection (i.e. during installation) and
@@ -1215,9 +1213,11 @@ function drupal_serve_page_from_cache(stdClass $cache) {
   $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
   $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
 
+  // Verify etag and if-modified-since.
   if ($if_modified_since && $if_none_match
-      && $if_none_match == $etag // etag must match
-      && $if_modified_since == $cache->created) {  // if-modified-since must match
+      && $if_none_match == $etag
+      && $if_modified_since == $cache->created) {
+
     header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
     drupal_send_headers($default_headers);
     return;
@@ -1232,8 +1232,8 @@ function drupal_serve_page_from_cache(stdClass $cache) {
 
   // HTTP/1.0 proxies does not support the Vary header, so prevent any caching
   // by sending an Expires date in the past. HTTP/1.1 clients ignores the
-  // Expires header if a Cache-Control: max-age= directive is specified (see RFC
-  // 2616, section 14.9.3).
+  // Expires header if a Cache-Control: max-age= directive is specified (see
+  // RFC 2616, section 14.9.3).
   $default_headers['Expires'] = 'Sun, 19 Nov 1978 05:00:00 GMT';
 
   drupal_send_headers($default_headers);
@@ -1536,19 +1536,20 @@ function request_uri() {
  */
 function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = WATCHDOG_ERROR, $link = NULL) {
 
-   // Use a default value if $message is not set.
-   if (empty($message)) {
-     // The exception message is run through check_plain() by _drupal_decode_exception().
-     $message = '%type: !message in %function (line %line of %file).';
-   }
-   // $variables must be an array so that we can add the exception information.
-   if (!is_array($variables)) {
-     $variables = array();
-   }
+  // Use a default value if $message is not set.
+  if (empty($message)) {
+    // The exception message is run through check_plain() by
+    // _drupal_decode_exception().
+    $message = '%type: !message in %function (line %line of %file).';
+  }
+  // $variables must be an array so that we can add the exception information.
+  if (!is_array($variables)) {
+    $variables = array();
+  }
 
-   require_once DRUPAL_ROOT . '/core/includes/errors.inc';
-   $variables += _drupal_decode_exception($exception);
-   watchdog($type, $message, $variables, $severity, $link);
+  require_once DRUPAL_ROOT . '/core/includes/errors.inc';
+  $variables += _drupal_decode_exception($exception);
+  watchdog($type, $message, $variables, $severity, $link);
 }
 
 /**
@@ -1581,15 +1582,16 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO
 
   static $in_error_state = FALSE;
 
-  // It is possible that the error handling will itself trigger an error. In that case, we could
-  // end up in an infinite loop. To avoid that, we implement a simple static semaphore.
+  // It is possible that the error handling will itself trigger an error. In
+  // that case, we could end up in an infinite loop. To avoid that, we
+  // implement a simple static semaphore.
   if (!$in_error_state && function_exists('module_implements')) {
     $in_error_state = TRUE;
 
-    // The user object may not exist in all conditions, so 0 is substituted if needed.
+    // The user object may not exist in all conditions, so 0 is substituted.
     $user_uid = isset($user->uid) ? $user->uid : 0;
 
-    // Prepare the fields to be logged
+    // Prepare the fields to be logged.
     $log_entry = array(
       'type'        => $type,
       'message'     => $message,
@@ -1604,7 +1606,7 @@ function watchdog($type, $message, $variables = array(), $severity = WATCHDOG_NO
       'timestamp'   => REQUEST_TIME,
     );
 
-    // Call the logging hooks to log/process the message
+    // Call the logging hooks to log/process the message.
     foreach (module_implements('watchdog') as $module) {
       module_invoke($module, 'watchdog', $log_entry);
     }
@@ -1696,7 +1698,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) {
 function drupal_get_title() {
   $title = drupal_set_title();
 
-  // During a bootstrap, menu.inc is not included and thus we cannot provide a title.
+  // During bootstrap, menu.inc is not included and we cannot provide a title.
   if (!isset($title) && function_exists('menu_get_active_title')) {
     $title = check_plain(menu_get_active_title());
   }
@@ -1761,7 +1763,7 @@ function drupal_is_denied($ip) {
   // database and also in this case it's quite likely that the user relies
   // on higher performance solutions like a firewall.
   elseif (class_exists('Database', FALSE)) {
-    $denied = (bool)db_query("SELECT 1 FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
+    $denied = (bool) db_query("SELECT 1 FROM {blocked_ips} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
   }
   return $denied;
 }
@@ -1792,7 +1794,7 @@ function drupal_block_denied($ip) {
  * @param $count
  *   The number of characters (bytes) to return in the string.
  */
-function drupal_random_bytes($count)  {
+function drupal_random_bytes($count) {
   // $random_state does not use drupal_static as it stores random bytes.
   static $random_state, $bytes, $php_compatible;
   // Initialize on the first call. The contents of $_SERVER includes a mix of
@@ -2112,7 +2114,8 @@ function _drupal_exception_handler($exception) {
   }
   catch (Exception $exception2) {
     // Another uncaught exception was thrown while handling the first one.
-    // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
+    // If we are displaying errors, then do so with no possibility of a further
+    // uncaught exception being thrown.
     if (error_displayable()) {
       print '<h1>Additional uncaught exception thrown while handling exception.</h1>';
       print '<h2>Original</h2><p>' . _drupal_render_exception_safe($exception) . '</p>';
@@ -2224,9 +2227,9 @@ function _drupal_bootstrap_database() {
     install_goto('core/install.php');
   }
 
-  // The user agent header is used to pass a database prefix in the request when
-  // running tests. However, for security reasons, it is imperative that we
-  // validate we ourselves made the request.
+  // The user agent header is used to pass a database prefix in the request
+  // when running tests. However, for security reasons, it is imperative that
+  // we validate we ourselves made the request.
   if ($test_prefix = drupal_valid_test_ua()) {
     // Set the test run id for use in other parts of Drupal.
     $test_info = &$GLOBALS['drupal_test_info'];
@@ -2273,7 +2276,8 @@ function _drupal_bootstrap_variables() {
   // Initialize the lock system.
   require_once DRUPAL_ROOT . '/core/includes/lock.inc';
 
-  // Load variables from the database, but do not overwrite variables set in settings.php.
+  // Load variables from the database, but do not overwrite variables set in 
+  // settings.php.
   $conf = variable_initialize(isset($conf) ? $conf : array());
   // Load bootstrap modules.
   require_once DRUPAL_ROOT . '/core/includes/module.inc';
@@ -2322,9 +2326,9 @@ function drupal_valid_test_ua() {
 
   if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/^(simpletest\d+);(.+);(.+);(.+)$/", $_SERVER['HTTP_USER_AGENT'], $matches)) {
     list(, $prefix, $time, $salt, $hmac) = $matches;
-    $check_string =  $prefix . ';' . $time . ';' . $salt;
-    // We use the salt from settings.php to make the HMAC key, since
-    // the database is not yet initialized and we can't access any Drupal variables.
+    $check_string = $prefix . ';' . $time . ';' . $salt;
+    // We use the salt from settings.php to make the HMAC key, since the 
+    // database is not yet initialized and we can't access variables.
     // The file properties add more entropy not easily accessible to others.
     $key = $drupal_hash_salt . filectime(__FILE__) . fileinode(__FILE__);
     $time_diff = REQUEST_TIME - $time;
@@ -2348,8 +2352,8 @@ function drupal_generate_test_ua($prefix) {
   static $key;
 
   if (!isset($key)) {
-    // We use the salt from settings.php to make the HMAC key, since
-    // the database is not yet initialized and we can't access any Drupal variables.
+    // We use the salt from settings.php to make the HMAC key, since the
+    // database is not yet initialized and we can't access variables.
     // The file properties add more entropy not easily accessible to others.
     $key = $drupal_hash_salt . filectime(__FILE__) . fileinode(__FILE__);
   }
@@ -2732,7 +2736,8 @@ function ip_address() {
         // Turn XFF header into an array.
         $forwarded = explode(',', $_SERVER[$reverse_proxy_header]);
 
-        // Trim the forwarded IPs; they may have been delimited by commas and spaces.
+        // Trim the forwarded IPs; they may have been delimited by commas and
+        // spaces.
         $forwarded = array_map('trim', $forwarded);
 
         // Tack direct client IP onto end of forwarded array.
@@ -2784,11 +2789,11 @@ function drupal_classloader() {
           $loader = new ApcUniversalClassLoader('drupal.' . $GLOBALS['drupal_hash_salt']);
           break;
         }
-      // Fall through to the default loader if APC was not loaded, so that the
-      // site does not fail completely.
       case 'dev':
       case 'default':
       default:
+        // Fall through to the default loader if APC was not loaded, so that
+        // the site does not fail completely.
         $loader = new UniversalClassLoader();
         break;
     }
@@ -3172,8 +3177,8 @@ function drupal_placeholder($text) {
  * @ingroup php_wrappers
  */
 function &drupal_register_shutdown_function($callback = NULL) {
-  // We cannot use drupal_static() here because the static cache is reset during
-  // batch processing, which breaks batch handling.
+  // We cannot use drupal_static() here because the static cache is reset
+  // during batch processing, which breaks batch handling.
   static $callbacks = array();
 
   if (isset($callback)) {
@@ -3183,7 +3188,7 @@ function &drupal_register_shutdown_function($callback = NULL) {
     }
     $args = func_get_args();
     array_shift($args);
-    // Save callback and arguments
+    // Save callback and arguments.
     $callbacks[] = array('callback' => $callback, 'arguments' => $args);
   }
   return $callbacks;
@@ -3205,9 +3210,10 @@ function _drupal_shutdown_function() {
     }
   }
   catch (Exception $exception) {
-    // If we are displaying errors, then do so with no possibility of a further uncaught exception being thrown.
-   require_once DRUPAL_ROOT . '/core/includes/errors.inc';
-   if (error_displayable()) {
+    // If we are displaying errors, then do so with no possibility of a
+    // further uncaught exception being thrown.
+    require_once DRUPAL_ROOT . '/core/includes/errors.inc';
+    if (error_displayable()) {
       print '<h1>Uncaught exception thrown in shutdown function.</h1>';
       print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
     }
-- 
1.7.5.4


From b67dec4da1174301bdd8b8adf9c9958343037ae0 Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Wed, 18 Apr 2012 01:15:18 +0000
Subject: [PATCH 7/8] Wide set of code standards fixes in common.inc

---
 core/includes/common.inc |  198 +++++++++++++++++++++++++++++++++------------
 1 files changed, 145 insertions(+), 53 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 7862f2d..d7f19fb 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -322,7 +322,7 @@ function _drupal_default_html_head() {
   );
   // Show Drupal and the major version number in the META GENERATOR tag.
   // Get the major version.
-  list($version, ) = explode('.', VERSION);
+  list($version,) = explode('.', VERSION);
   $elements['system_meta_generator'] = array(
     '#type' => 'html_tag',
     '#tag' => 'meta',
@@ -667,7 +667,8 @@ function drupal_encode_path($path) {
  */
 function drupal_goto($path = '', array $options = array(), $http_response_code = 302) {
   // A destination in $_GET always overrides the function arguments.
-  // We do not allow absolute URLs to be passed via $_GET, as this can be an attack vector.
+  // We do not allow absolute URLs to be passed via $_GET, as this can be an
+  // attack vector.
   if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
     $destination = drupal_parse_url($_GET['destination']);
     $path = $destination['path'];
@@ -808,12 +809,14 @@ function drupal_http_request($url, array $options = array()) {
       // checking the host that do not take into account the port number.
       $options['headers']['Host'] = $uri['host'] . ($port != 80 ? ':' . $port : '');
       break;
+
     case 'https':
       // Note: Only works when PHP is compiled with OpenSSL support.
       $port = isset($uri['port']) ? $uri['port'] : 443;
       $socket = 'ssl://' . $uri['host'] . ':' . $port;
       $options['headers']['Host'] = $uri['host'] . ($port != 443 ? ':' . $port : '');
       break;
+
     default:
       $result->error = 'invalid schema ' . $uri['scheme'];
       $result->code = -1003;
@@ -869,12 +872,12 @@ function drupal_http_request($url, array $options = array()) {
     $options['headers']['Authorization'] = 'Basic ' . base64_encode($uri['user'] . (isset($uri['pass']) ? ':' . $uri['pass'] : ''));
   }
 
-  // If the database prefix is being used by SimpleTest to run the tests in a copied
-  // database then set the user-agent header to the database prefix so that any
-  // calls to other Drupal pages will run the SimpleTest prefixed database. The
-  // user-agent is used to ensure that multiple testing sessions running at the
-  // same time won't interfere with each other as they would if the database
-  // prefix were stored statically in a file or database variable.
+  // If the database prefix is being used by SimpleTest to run the tests in a
+  // copied database then set the user-agent header to the database prefix so
+  // that any calls to other Drupal pages will run the SimpleTest prefixed
+  // database. The user-agent is used to ensure that multiple testing sessions
+  // running at the same time won't interfere with each other as they would if
+  // the database prefix were stored statically in a file or database variable.
   $test_info = &$GLOBALS['drupal_test_info'];
   if (!empty($test_info['test_run_id'])) {
     $options['headers']['User-Agent'] = drupal_generate_test_ua($test_info['test_run_id']);
@@ -1000,6 +1003,7 @@ function drupal_http_request($url, array $options = array()) {
     case 200: // OK
     case 304: // Not modified
       break;
+
     case 301: // Moved permanently
     case 302: // Moved temporarily
     case 307: // Moved temporarily
@@ -1019,6 +1023,7 @@ function drupal_http_request($url, array $options = array()) {
         $result->redirect_url = $location;
       }
       break;
+
     default:
       $result->error = $status_message;
   }
@@ -1108,7 +1113,7 @@ function fix_gpc_magic() {
  *   TRUE if the address is in a valid format.
  */
 function valid_email_address($mail) {
-  return (bool)filter_var($mail, FILTER_VALIDATE_EMAIL);
+  return (bool) filter_var($mail, FILTER_VALIDATE_EMAIL);
 }
 
 /**
@@ -1127,7 +1132,7 @@ function valid_email_address($mail) {
  */
 function valid_url($url, $absolute = FALSE) {
   if ($absolute) {
-    return (bool)preg_match("
+    return (bool) preg_match("
       /^                                                      # Start at the beginning of the text
       (?:ftp|https?|feed):\/\/                                # Look for ftp, http, https or feed schemes
       (?:                                                     # Userinfo (optional) which is typically
@@ -1145,7 +1150,7 @@ function valid_url($url, $absolute = FALSE) {
     $/xi", $url);
   }
   else {
-    return (bool)preg_match("/^(?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})+$/i", $url);
+    return (bool) preg_match("/^(?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})+$/i", $url);
   }
 }
 
@@ -1190,7 +1195,7 @@ function valid_number_step($value, $step, $offset = 0.0) {
   // can't be represented with single precision floats are acceptable. The
   // fractional part of a float has 24 bits. That means remainders smaller than
   // $step * 2^-24 are acceptable.
-  $computed_acceptable_error = (double)($step / pow(2.0, 24));
+  $computed_acceptable_error = (double) ($step / pow(2.0, 24));
 
   return $computed_acceptable_error >= $remainder || $remainder >= ($step - $computed_acceptable_error);
 }
@@ -1624,7 +1629,7 @@ function _filter_xss_attributes($attr) {
  *   Cleaned up and HTML-escaped version of $string.
  */
 function filter_xss_bad_protocol($string, $decode = TRUE) {
-  // Get the plain text representation of the attribute value (i.e. its meaning).
+  // Get the plain text representation of the attribute value.
   // @todo Remove the $decode parameter in Drupal 8, and always assume an HTML
   //   string that needs decoding.
   if ($decode) {
@@ -1817,10 +1822,13 @@ function format_plural($count, $singular, $plural, array $args = array(), array
  *   An integer representation of the size in bytes.
  */
 function parse_size($size) {
-  $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
-  $size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
+  // Remove the non-unit characters from the size.
+  $unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
+  // Remove the non-numeric characters from the size.
+  $size = preg_replace('/[^0-9\.]/', '', $size);
   if ($unit) {
-    // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
+    // Find the position of the unit in the ordered string which is the power
+    // of magnitude to multiply a kilobyte by.
     return round($size * pow(DRUPAL_KILOBYTE, stripos('bkmgtpezy', $unit[0])));
   }
   else {
@@ -1845,7 +1853,8 @@ function format_size($size, $langcode = NULL) {
     return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
   }
   else {
-    $size = $size / DRUPAL_KILOBYTE; // Convert bytes to kilobytes.
+    // Convert bytes to kilobytes.
+    $size = $size / DRUPAL_KILOBYTE;
     $units = array(
       t('@size KB', array(), array('langcode' => $langcode)),
       t('@size MB', array(), array('langcode' => $langcode)),
@@ -1890,7 +1899,7 @@ function format_interval($interval, $granularity = 2, $langcode = NULL) {
     '1 day|@count days' => 86400,
     '1 hour|@count hours' => 3600,
     '1 min|@count min' => 60,
-    '1 sec|@count sec' => 1
+    '1 sec|@count sec' => 1,
   );
   $output = '';
   foreach ($units as $key => $value) {
@@ -2164,7 +2173,7 @@ function url($path = NULL, array $options = array()) {
     'query' => array(),
     'absolute' => FALSE,
     'alias' => FALSE,
-    'prefix' => ''
+    'prefix' => '',
   );
 
   if (!isset($options['external'])) {
@@ -2413,14 +2422,15 @@ function l($text, $path, array $options = array()) {
     $options['attributes']['class'][] = 'active';
   }
 
-  // Remove all HTML and PHP tags from a tooltip. For best performance, we act only
-  // if a quick strpos() pre-check gave a suspicion (because strip_tags() is expensive).
+  // Remove all HTML and PHP tags from a tooltip. For best performance, we act
+  // only if a quick strpos() pre-check gave a suspicion (because strip_tags()
+  // is expensive).
   if (isset($options['attributes']['title']) && strpos($options['attributes']['title'], '<') !== FALSE) {
     $options['attributes']['title'] = strip_tags($options['attributes']['title']);
   }
 
-  // Determine if rendering of the link is to be done with a theme function
-  // or the inline default. Inline is faster, but if the theme system has been
+  // Determine if rendering of the link is to be done with a theme function or
+  // the inline default. Inline is faster, but if the theme system has been
   // loaded and a module or theme implements a preprocess or process function
   // or overrides the theme_link() function, then invoke theme(). Preliminary
   // benchmarks indicate that invoking theme() can slow down the l() function
@@ -2433,11 +2443,11 @@ function l($text, $path, array $options = array()) {
       drupal_theme_initialize();
       $registry = theme_get_registry(FALSE);
       // We don't want to duplicate functionality that's in theme(), so any
-      // hint of a module or theme doing anything at all special with the 'link'
-      // theme hook should simply result in theme() being called. This includes
-      // the overriding of theme_link() with an alternate function or template,
-      // the presence of preprocess or process functions, or the presence of
-      // include files.
+      // hint of a module or theme doing anything at all special with the
+      // 'link' theme hook should simply result in theme() being called. This
+      // includes the overriding of theme_link() with an alternate function or
+      // template, the presence of preprocess or process functions, or the
+      // presence of include files.
       $use_theme = !isset($registry['link']['function']) || ($registry['link']['function'] != 'theme_link');
       $use_theme = $use_theme || !empty($registry['link']['preprocess functions']) || !empty($registry['link']['process functions']) || !empty($registry['link']['includes']);
     }
@@ -2448,8 +2458,8 @@ function l($text, $path, array $options = array()) {
   if ($use_theme) {
     return theme('link', array('text' => $text, 'path' => $path, 'options' => $options));
   }
-  // The result of url() is a plain-text URL. Because we are using it here
-  // in an HTML argument context, we need to encode it properly.
+  // The result of url() is a plain-text URL. Because we are using it here in
+  // an HTML argument context, we need to encode it properly.
   return '<a href="' . check_plain(url($path, $options)) . '"' . drupal_attributes($options['attributes']) . '>' . ($options['html'] ? $text : check_plain($text)) . '</a>';
 }
 
@@ -2817,7 +2827,11 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
     // Also add a HTTP header "Link:".
     $href = '<' . check_plain($attributes['href']) . '>;';
     unset($attributes['href']);
-    $element['#attached']['drupal_add_http_header'][] = array('Link',  $href . drupal_http_header_attributes($attributes), TRUE);
+    $element['#attached']['drupal_add_http_header'][] = array(
+      'Link',
+      $href . drupal_http_header_attributes($attributes),
+      TRUE,
+    );
   }
 
   drupal_add_html_head($element, 'drupal_add_html_head_link:' . $attributes['rel'] . ':' . $href);
@@ -2952,8 +2966,8 @@ function drupal_add_css($data = NULL, $options = NULL) {
     $options = array();
   }
 
-  // Create an array of CSS files for each media type first, since each type needs to be served
-  // to the browser differently.
+  // Create an array of CSS files for each media type first, since each type
+  // needs to be served to the browser differently.
   if (isset($data)) {
     $options += array(
       'type' => 'file',
@@ -2985,6 +2999,7 @@ function drupal_add_css($data = NULL, $options = NULL) {
         // key as $data could be a very long string of CSS.
         $css[] = $options;
         break;
+
       default:
         // Local and external files must keep their name as the associative key
         // so the same CSS file is not be added twice.
@@ -3181,8 +3196,8 @@ function drupal_group_css($css) {
 
     // If the item can be grouped with other items, set $group_keys to an array
     // of information that must be the same for all items in its group. If the
-    // item can't be grouped with other items, set $group_keys to FALSE. We
-    // put items into a group that can be aggregated together: whether they will
+    // item can't be grouped with other items, set $group_keys to FALSE. We put
+    // items into a group that can be aggregated together: whether they will
     // be aggregated is up to the _drupal_css_aggregate() function or an
     // override of that function specified in hook_css_alter(), but regardless
     // of the details of that function, a group represents items that can be
@@ -3197,10 +3212,12 @@ function drupal_group_css($css) {
         // flag. See drupal_add_css() for details about that.
         $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['media'], $item['browsers']) : FALSE;
         break;
+
       case 'inline':
         // Always group inline items.
         $group_keys = array($item['type'], $item['media'], $item['browsers']);
         break;
+
       case 'external':
         // Do not group external items.
         $group_keys = FALSE;
@@ -3265,8 +3282,9 @@ function drupal_aggregate_css(&$css_groups) {
           $css_groups[$key]['data'] = drupal_build_css_cache($group['items']);
         }
         break;
-      // Aggregate all inline CSS content into the group's data property.
+
       case 'inline':
+        // Aggregate all inline CSS content into the group's data property.
         $css_groups[$key]['data'] = '';
         foreach ($group['items'] as $item) {
           $css_groups[$key]['data'] .= drupal_load_stylesheet_content($item['data'], $item['preprocess']);
@@ -3454,10 +3472,11 @@ function drupal_pre_render_styles($elements) {
           }
         }
         break;
-      // For inline content, the 'data' property contains the CSS content. If
-      // the group's 'data' property is set, then output it in a single STYLE
-      // tag. Otherwise, output a separate STYLE tag for each item.
+
       case 'inline':
+        // For inline content, the 'data' property contains the CSS content. If
+        // the group's 'data' property is set, then output it in a single STYLE
+        // tag. Otherwise, output a separate STYLE tag for each item.
         if (isset($group['data'])) {
           $element = $style_element_defaults;
           $element['#value'] = $group['data'];
@@ -6862,16 +6881,29 @@ function drupal_common_theme() {
       'template' => 'region',
     ),
     'datetime' => array(
-      'variables' => array('timestamp' => NULL, 'text' => NULL, 'attributes' => array(), 'html' => FALSE),
+      'variables' => array(
+        'timestamp' => NULL,
+        'text' => NULL,
+        'attributes' => array(),
+        'html' => FALSE,
+      ),
     ),
     'status_messages' => array(
       'variables' => array('display' => NULL),
     ),
     'link' => array(
-      'variables' => array('text' => NULL, 'path' => NULL, 'options' => array()),
+      'variables' => array(
+        'text' => NULL,
+        'path' => NULL,
+        'options' => array(),
+      ),
     ),
     'links' => array(
-      'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array()),
+      'variables' => array(
+        'links' => array(),
+        'attributes' => array('class' => array('links')),
+        'heading' => array(),
+      ),
     ),
     'image' => array(
       // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
@@ -6886,7 +6918,14 @@ function drupal_common_theme() {
       // - http://dev.w3.org/html5/spec/Overview.html#alt
       // The title attribute is optional in all cases, so it is omitted by
       // default.
-      'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array()),
+      'variables' => array(
+        'uri' => NULL,
+        'width' => NULL,
+        'height' => NULL,
+        'alt' => '',
+        'title' => NULL,
+        'attributes' => array(),
+      ),
     ),
     'breadcrumb' => array(
       'variables' => array('breadcrumb' => NULL),
@@ -6895,10 +6934,29 @@ function drupal_common_theme() {
       'variables' => array(),
     ),
     'table' => array(
-      'variables' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => TRUE, 'empty' => ''),
+      'variables' => array(
+        'header' => NULL,
+        'rows' => NULL,
+        'attributes' => array(),
+        'caption' => NULL,
+        'colgroups' => array(),
+        'sticky' => TRUE,
+        'empty' => '',
+      ),
     ),
     'meter' => array(
-      'variables' => array('display_value' => NULL, 'form' => NULL, 'high' => NULL, 'low' => NULL, 'max' => NULL, 'min' => NULL, 'optimum' => NULL, 'value' => NULL, 'percentage' => NULL, 'attributes' => array()),
+      'variables' => array(
+        'display_value' => NULL,
+        'form' => NULL,
+        'high' => NULL,
+        'low' => NULL,
+        'max' => NULL,
+        'min' => NULL,
+        'optimum' => NULL,
+        'value' => NULL,
+        'percentage' => NULL,
+        'attributes' => array()
+      ),
     ),
     'tablesort_indicator' => array(
       'variables' => array('style' => NULL),
@@ -6907,7 +6965,12 @@ function drupal_common_theme() {
       'variables' => array('type' => MARK_NEW),
     ),
     'item_list' => array(
-      'variables' => array('items' => array(), 'title' => '', 'type' => 'ul', 'attributes' => array()),
+      'variables' => array(
+        'items' => array(),
+        'title' => '',
+        'type' => 'ul',
+        'attributes' => array(),
+      ),
     ),
     'more_help_link' => array(
       'variables' => array('url' => NULL),
@@ -6949,22 +7012,51 @@ function drupal_common_theme() {
     ),
     // From pager.inc.
     'pager' => array(
-      'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array(), 'quantity' => 9),
+      'variables' => array(
+        'tags' => array(),
+        'element' => 0,
+        'parameters' => array(),
+        'quantity' => 9,
+      ),
     ),
     'pager_first' => array(
-      'variables' => array('text' => NULL, 'element' => 0, 'parameters' => array()),
+      'variables' => array(
+        'text' => NULL,
+        'element' => 0,
+        'parameters' => array(),
+      ),
     ),
     'pager_previous' => array(
-      'variables' => array('text' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
+      'variables' => array(
+        'text' => NULL,
+        'element' => 0,
+        'interval' => 1,
+        'parameters' => array(),
+      ),
     ),
     'pager_next' => array(
-      'variables' => array('text' => NULL, 'element' => 0, 'interval' => 1, 'parameters' => array()),
+      'variables' => array(
+        'text' => NULL,
+        'element' => 0,
+        'interval' => 1,
+        'parameters' => array(),
+      ),
     ),
     'pager_last' => array(
-      'variables' => array('text' => NULL, 'element' => 0, 'parameters' => array()),
+      'variables' => array(
+        'text' => NULL,
+        'element' => 0,
+        'parameters' => array()
+      ),
     ),
     'pager_link' => array(
-      'variables' => array('text' => NULL, 'page_new' => NULL, 'element' => NULL, 'parameters' => array(), 'attributes' => array()),
+      'variables' => array(
+        'text' => NULL,
+        'page_new' => NULL,
+        'element' => NULL,
+        'parameters' => array(),
+        'attributes' => array(),
+      ),
     ),
     // From menu.inc.
     'menu_link' => array(
@@ -7537,7 +7629,7 @@ function archiver_get_extensions() {
  *   If no appropriate archiver class was found, will return FALSE.
  */
 function archiver_get_archiver($file) {
-  // Archivers can only work on local paths
+  // Ensure file is a local path.
   $filepath = drupal_realpath($file);
   if (!is_file($filepath)) {
     throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file)));
-- 
1.7.5.4


From 7f5200ac5098899560cdbfe5e205894dd08a3307 Mon Sep 17 00:00:00 2001
From: Gregory Perry <lotyrin@gmail.com>
Date: Wed, 18 Apr 2012 01:23:04 +0000
Subject: [PATCH 8/8] Some code standards fixes in common.inc

---
 core/includes/config.inc |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/core/includes/config.inc b/core/includes/config.inc
index 75b68bf..206dda0 100644
--- a/core/includes/config.inc
+++ b/core/includes/config.inc
@@ -39,7 +39,7 @@ function config_install_default_config($module) {
   $module_config_dir = drupal_get_path('module', $module) . '/config';
   $drupal_config_dir = config_get_config_directory();
   if (is_dir(drupal_get_path('module', $module) . '/config')) {
-    $files = glob($module_config_dir . '/' . '*.xml');
+    $files = glob($module_config_dir . '/*.xml');
     foreach ($files as $key => $file) {
       // Load config data into the active store and write it out to the
       // file system in the drupal config directory. Note the config name
@@ -89,7 +89,8 @@ function config_get_signed_file_storage_names_with_prefix($prefix = '') {
  *   A hash of the data.
  */
 function config_sign_data($data) {
-  // The configuration key is loaded from settings.php and imported into the global namespace
+  // The configuration key is loaded from settings.php and imported into the
+  // global namespace.
   global $config_signature_key;
 
   // SHA-512 is both secure and very fast on 64 bit CPUs.
-- 
1.7.5.4

