diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-10-22 15:14:46 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-10-22 15:14:46 +0000 |
commit | f6764cfbd8dcdedd05263711a41fcedb72dda2ab (patch) | |
tree | 88f659fea364fc50d3173da0c5a8bdbc28be8557 /includes | |
parent | 07ecb2abb0206484a77acbf5ba767af856d99520 (diff) | |
download | brdo-f6764cfbd8dcdedd05263711a41fcedb72dda2ab.tar.gz brdo-f6764cfbd8dcdedd05263711a41fcedb72dda2ab.tar.bz2 |
- Patch #30930 by m3avrck/deekayen: cured PHP5 warnings.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/bootstrap.inc | 13 | ||||
-rw-r--r-- | includes/common.inc | 12 | ||||
-rw-r--r-- | includes/image.inc | 3 | ||||
-rw-r--r-- | includes/menu.inc | 13 | ||||
-rw-r--r-- | includes/pager.inc | 8 | ||||
-rw-r--r-- | includes/theme.inc | 4 | ||||
-rw-r--r-- | includes/xmlrpc.inc | 6 | ||||
-rw-r--r-- | includes/xmlrpcs.inc | 6 |
8 files changed, 41 insertions, 24 deletions
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 02618277f..5f72665cd 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -148,14 +148,14 @@ function conf_init() { function drupal_get_filename($type, $name, $filename = NULL) { static $files = array(); - if (!$files[$type]) { + if (!isset($files[$type])) { $files[$type] = array(); } - if ($filename && file_exists($filename)) { + if (!empty($filename) && file_exists($filename)) { $files[$type][$name] = $filename; } - elseif ($files[$type][$name]) { + elseif (isset($files[$type][$name])) { // nothing } elseif (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file)) { @@ -722,7 +722,7 @@ function check_url($uri) { /** * Since request_uri() is only available on Apache, we generate an - * equivalent using other environment vars. + * equivalent using other environment variables. */ function request_uri() { @@ -788,7 +788,8 @@ function drupal_set_message($message = NULL, $type = 'status') { $_SESSION['messages'][$type][] = $message; } - return $_SESSION['messages']; + // messages not set when DB connection fails + return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL; } /** @@ -867,7 +868,7 @@ function _drupal_bootstrap($phase) { // deny access to hosts which were banned. t() is not yet available. if (drupal_is_denied('host', $_SERVER['REMOTE_ADDR'])) { header('HTTP/1.0 403 Forbidden'); - print "Sorry, ". $_SERVER['REMOTE_ADDR']. " has been banned."; + print 'Sorry, '. $_SERVER['REMOTE_ADDR']. ' has been banned.'; exit(); } diff --git a/includes/common.inc b/includes/common.inc index 953339300..f3e95a2fe 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -53,10 +53,8 @@ function drupal_set_content($region = null, $data = null) { */ function drupal_get_content($region = null, $delimiter = ' ') { $content = drupal_set_content(); - if (isset($region)) { - if (is_array($content[$region])) { + if (isset($region) && isset($content[$region]) && is_array($content[$region])) { return implode ($delimiter, $content[$region]); - } } else { foreach (array_keys($content) as $region) { @@ -78,7 +76,7 @@ function drupal_get_content($region = null, $delimiter = ' ') { function drupal_set_breadcrumb($breadcrumb = NULL) { static $stored_breadcrumb; - if (isset($breadcrumb)) { + if (!is_null($breadcrumb)) { $stored_breadcrumb = $breadcrumb; } return $stored_breadcrumb; @@ -90,7 +88,7 @@ function drupal_set_breadcrumb($breadcrumb = NULL) { function drupal_get_breadcrumb() { $breadcrumb = drupal_set_breadcrumb(); - if (!isset($breadcrumb)) { + if (is_null($breadcrumb)) { $breadcrumb = menu_get_active_breadcrumb(); } @@ -569,7 +567,7 @@ function locale_initialize() { // Useful for e.g. XML/HTML 'lang' attributes. $languages = array('en' => 'English'); } - if ($user->uid && $languages[$user->language]) { + if ($user->uid && isset($languages[$user->language])) { return $user->language; } else { @@ -1298,7 +1296,7 @@ function drupal_implode_autocomplete($array) { /** * Wrapper around urlencode() which avoids Apache quirks. * - * Should be used when placing arbitrary data inside the path of a clean URL. + * Should be used when placing arbitrary data inside the path of a clean URL. * * @param $text * String to encode diff --git a/includes/image.inc b/includes/image.inc index 9dea8d52c..a4cf79b44 100644 --- a/includes/image.inc +++ b/includes/image.inc @@ -125,7 +125,8 @@ function image_scale($source, $destination, $width, $height) { if ($aspect < $height / $width) { $width = (int)min($width, $info['width']); $height = (int)round($width * $aspect); - } else { + } + else { $height = (int)min($height, $info['height']); $width = (int)round($height / $aspect); } diff --git a/includes/menu.inc b/includes/menu.inc index 826d1c0ed..9fc2ab465 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -742,7 +742,18 @@ function _menu_sort($a, $b) { $a = &$menu['items'][$a]; $b = &$menu['items'][$b]; - return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1)); + if ($a['weight'] < $b['weight']) { + return -1; + } + elseif ($a['weight'] > $b['weight']) { + return 1; + } + elseif (isset($a['title']) && isset($b['title']) && ($a['title'] < $b['title'])) { + return -1; + } + else { + return 1; + } } /** diff --git a/includes/pager.inc b/includes/pager.inc index 959ce321b..58891986e 100644 --- a/includes/pager.inc +++ b/includes/pager.inc @@ -50,13 +50,13 @@ */ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { global $pager_page_array, $pager_total, $pager_total_items; - $page = $_GET['page']; + $page = isset($_GET['page']) ? $_GET['page'] : ''; // Substitute in query arguments. $args = func_get_args(); $args = array_slice($args, 4); // Alternative syntax for '...' - if (is_array($args[0])) { + if (isset($args[0]) && is_array($args[0])) { $args = $args[0]; } @@ -72,13 +72,13 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { if (count($args)) { $pager_total_items[$element] = db_result(db_query($count_query, $args)); $pager_total[$element] = ceil($pager_total_items[$element] / $limit); - $pager_page_array[$element] = max(0, min($pager_page_array[$element], ((int)$pager_total[$element]) - 1)); + $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1)); return db_query_range($query, $args, $pager_page_array[$element] * $limit, $limit); } else { $pager_total_items[$element] = db_result(db_query($count_query)); $pager_total[$element] = ceil($pager_total_items[$element] / $limit); - $pager_page_array[$element] = max(0, min($pager_page_array[$element], ((int)$pager_total[$element]) - 1)); + $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1)); return db_query_range($query, $pager_page_array[$element] * $limit, $limit); } } diff --git a/includes/theme.inc b/includes/theme.inc index b90d6505e..f345be9dc 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -316,7 +316,9 @@ function theme_get_setting($setting_name, $refresh = FALSE) { // Get the amount of links to show, possibly expanding if there are more links defined than the count specifies. $count = variable_get($type . '_link_count', 5); - $count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']); + if (isset($value['link']) && $count > sizeof($value['link'])) { + $count = sizeof($value['link']); + } if ($settings['toggle_' . $type . '_links']) { for ($i =0; $i < $count; $i++) { diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc index 4ed533c6b..a31d53e11 100644 --- a/includes/xmlrpc.inc +++ b/includes/xmlrpc.inc @@ -232,11 +232,13 @@ function xmlrpc_message_tag_close($parser, $tag) { if ($xmlrpc_message->array_structs_types[count($xmlrpc_message->array_structs_types)-1] == 'struct') { // Add to struct $xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][$xmlrpc_message->current_struct_name[count($xmlrpc_message->current_struct_name)-1]] = $value; - } else { + } + else { // Add to array $xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][] = $value; } - } else { + } + else { // Just add as a paramater $xmlrpc_message->params[] = $value; } diff --git a/includes/xmlrpcs.inc b/includes/xmlrpcs.inc index 26b004159..35acdeb95 100644 --- a/includes/xmlrpcs.inc +++ b/includes/xmlrpcs.inc @@ -124,7 +124,8 @@ function xmlrpc_server_multicall($methodcalls) { $params = $call['params']; if ($method == 'system.multicall') { $result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden')); - } else { + } + else { $result = xmlrpc_server_call($xmlrpc_server, $method, $params); } if ($result->is_error) { @@ -132,7 +133,8 @@ function xmlrpc_server_multicall($methodcalls) { 'faultCode' => $result->code, 'faultString' => $result->message ); - } else { + } + else { $return[] = $result; } } |