From f7440d4d73ec57219af232c135be3b2567dda45f Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Tue, 27 Mar 2007 05:13:55 +0000 Subject: #130971: Kitchen sink (E_NOTICE compliance / Code style / Bugfix in book toc) --- includes/bootstrap.inc | 4 +++- includes/common.inc | 9 ++++++++- includes/file.inc | 2 +- includes/form.inc | 11 +++++++++-- includes/install.inc | 2 +- includes/locale.inc | 2 +- includes/menu.inc | 5 +++-- includes/session.inc | 4 ++-- includes/theme.inc | 5 ++++- 9 files changed, 32 insertions(+), 12 deletions(-) (limited to 'includes') diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 26fa25ec2..3b3d1589f 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -355,7 +355,9 @@ function drupal_get_filename($type, $name, $filename = NULL) { } } - return $files[$type][$name]; + if (isset($files[$type][$name])) { + return $files[$type][$name]; + } } /** diff --git a/includes/common.inc b/includes/common.inc index a51891caf..37cf2f8f9 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -351,6 +351,7 @@ function drupal_not_found() { if (empty($return)) { drupal_set_title(t('Page not found')); + $return = ''; } // To conserve CPU and bandwidth, omit the blocks print theme('page', $return, FALSE); @@ -871,6 +872,7 @@ function format_rss_item($title, $link, $description, $args = array()) { * with the same format as $array itself for nesting. */ function format_xml_elements($array) { + $output = ''; foreach ($array as $key => $value) { if (is_numeric($key)) { if ($value['key']) { @@ -1972,7 +1974,12 @@ function drupal_mail($mailkey, $to, $subject, $body, $from = NULL, $headers = ar // Bundle up the variables into a structured array for altering. $message = array('#mail_id' => $mailkey, '#to' => $to, '#subject' => $subject, '#body' => $body, '#from' => $from, '#headers' => $headers); drupal_alter('mail', $message); - list($mailkey, $to, $subject, $body, $from, $headers) = $message; + $mailkey = $message['#mail_id']; + $to = $message['#to']; + $subject = $message['#subject']; + $body = $message['#body']; + $from = $message['#from']; + $headers = $message['#headers']; // Allow for custom mail backend if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) { diff --git a/includes/file.inc b/includes/file.inc index 5afc66b0d..18bf144cd 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -382,7 +382,7 @@ function file_copy(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { @chmod($dest, 0664); } - if (is_object($file)) { + if (isset($file) && is_object($file)) { $file->filename = $basename; $file->filepath = $dest; $source = $file; diff --git a/includes/form.inc b/includes/form.inc index f7d166f11..63b3b52dd 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -319,7 +319,7 @@ function drupal_prepare_form($form_id, &$form) { $form['form_token'] = array('#type' => 'token', '#default_value' => drupal_get_token($form['#token'])); } } - else if ($user->uid && !$form['#programmed']) { + else if (isset($user->uid) && $user->uid && !$form['#programmed']) { $form['#token'] = $form_id; $form['form_token'] = array( '#id' => form_clean_id('edit-'. $form_id .'-form-token'), @@ -1263,7 +1263,14 @@ function expand_radios($element) { if (count($element['#options']) > 0) { foreach ($element['#options'] as $key => $choice) { if (!isset($element[$key])) { - $element[$key] = array('#type' => 'radio', '#title' => $choice, '#return_value' => $key, '#default_value' => $element['#default_value'], '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#spawned' => TRUE); + $element[$key] = array( + '#type' => 'radio', + '#title' => $choice, + '#return_value' => $key, + '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL, + '#attributes' => $element['#attributes'], + '#parents' => $element['#parents'], + ); } } } diff --git a/includes/install.inc b/includes/install.inc index 961e8efa4..940df006f 100644 --- a/includes/install.inc +++ b/includes/install.inc @@ -204,7 +204,7 @@ function drupal_rewrite_settings($settings = array(), $prefix = '') { // Write new value to settings.php in the following format: // $'setting' = 'value'; // 'comment' $setting = $settings[$variable[1]]; - $buffer .= '$'. $variable[1] ." = '". $setting['value'] ."';". ($setting['comment'] ? ' // '. $setting['comment'] ."\n" : "\n"); + $buffer .= '$'. $variable[1] ." = '". $setting['value'] ."';". (!empty($setting['comment']) ? ' // '. $setting['comment'] ."\n" : "\n"); unset($settings[$variable[1]]); } else { diff --git a/includes/locale.inc b/includes/locale.inc index d526a33de..825f438a0 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -1301,7 +1301,7 @@ function _locale_import_parse_quoted($string) { */ function _locale_export_po($language) { global $user; - + $header = ''; // Get language specific strings, or all strings if ($language) { $meta = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $language)); diff --git a/includes/menu.inc b/includes/menu.inc index 435f694d4..87e5b34b8 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -632,7 +632,8 @@ function menu_rebuild() { $item = &$menu[$path]; $number_parts = $item['_number_parts']; if (isset($item['parent'])) { - $parent_parts = explode('/', $menu_path_map[$item['parent']], 6); + $item['parent'] = $menu_path_map[$item['parent']]; + $parent_parts = explode('/', $item['parent'], 6); $slashes = count($parent_parts) - 1; } else { @@ -723,7 +724,7 @@ function menu_rebuild() { $item['parent'] = implode('/', array_slice($item['_parts'], 0, $item['_number_parts'] - 1)); } else { - $item['_depth'] = $item['parent'] ? $menu[$menu_path_map[$item['parent']]]['_depth'] + 1 : 1; + $item['_depth'] = $item['parent'] ? $menu[$item['parent']]['_depth'] + 1 : 1; } } else { diff --git a/includes/session.inc b/includes/session.inc index 922f0611a..97379907c 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -70,11 +70,11 @@ function sess_write($key, $value) { // session table rows without breaking throttle module and "Who's Online" // block. if ($user->uid || $value || count($_COOKIE)) { - db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time()); + db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time()); } } else { - db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, $user->cache, $_SERVER["REMOTE_ADDR"], $value, time(), $key); + db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', $_SERVER["REMOTE_ADDR"], $value, time(), $key); // TODO: this can be an expensive query. Perhaps only execute it every x minutes. Requires investigation into cache expiration. if ($user->uid) { diff --git a/includes/theme.inc b/includes/theme.inc index d4a412751..267240b16 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -611,7 +611,7 @@ function theme_links($links, $attributes = array('class' => 'links')) { // Pass in $link as $options, they share the same keys. $output .= l($link['title'], $link['href'], $link); } - else if ($link['title']) { + else if (!empty($link['title'])) { // Some links are actually not links, but we wrap these in for adding title and class attributes if (empty($link['html'])) { $link['title'] = check_plain($link['title']); @@ -810,6 +810,9 @@ function theme_table($header, $rows, $attributes = array(), $caption = NULL) { } $output .= " \n"; } + else { + $ts = array(); + } // Format the table rows: $output .= "\n"; -- cgit v1.2.3