summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/common.inc5
-rw-r--r--includes/file.inc4
-rw-r--r--includes/form.inc55
-rw-r--r--includes/menu.inc18
-rw-r--r--includes/module.inc4
-rw-r--r--includes/tablesort.inc3
-rw-r--r--includes/theme.inc6
-rw-r--r--modules/aggregator/aggregator.module8
-rw-r--r--modules/block/block.module10
-rw-r--r--modules/blog/blog.module6
-rw-r--r--modules/book/book.module7
-rw-r--r--modules/comment/comment.module19
-rw-r--r--modules/contact/contact.module2
-rw-r--r--modules/filter/filter.module9
-rw-r--r--modules/forum/forum.module8
-rw-r--r--modules/locale/locale.module2
-rw-r--r--modules/node/node.module32
-rw-r--r--modules/path/path.module7
-rw-r--r--modules/profile/profile.module3
-rw-r--r--modules/statistics/statistics.module7
-rw-r--r--modules/system/system.install2
-rw-r--r--modules/system/system.module56
-rw-r--r--modules/taxonomy/taxonomy.module24
-rw-r--r--modules/upload/upload.module10
-rw-r--r--modules/user/user.module31
-rw-r--r--modules/watchdog/watchdog.module3
-rw-r--r--sites/default/settings.php2
-rw-r--r--themes/bluemarine/comment.tpl.php2
-rw-r--r--themes/garland/comment.tpl.php2
29 files changed, 196 insertions, 151 deletions
diff --git a/includes/common.inc b/includes/common.inc
index a7ea1cab5..1512f30ce 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1450,6 +1450,8 @@ function drupal_get_css($css = NULL) {
if (!isset($css)) {
$css = drupal_add_css();
}
+ $no_module_preprocess = '';
+ $no_theme_preprocess = '';
$preprocess_css = variable_get('preprocess_css', FALSE);
$directory = file_directory_path();
@@ -2120,6 +2122,7 @@ function drupal_render(&$elements) {
if (!isset($elements['#sorted'])) {
uasort($elements, "_element_sort");
}
+ $elements += array('#title' => NULL, '#description' => NULL);
if (!isset($elements['#children'])) {
$children = element_children($elements);
/* Render all the children that use a theme function */
@@ -2201,7 +2204,7 @@ function element_properties($element) {
* Check if the key is a child.
*/
function element_child($key) {
- return $key[0] != '#';
+ return !isset($key[0]) || $key[0] != '#';
}
/**
diff --git a/includes/file.inc b/includes/file.inc
index 702641312..4b8e3c6e3 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -193,7 +193,7 @@ function file_check_upload($source = 'upload') {
}
// If a file was uploaded, process it.
- if ($_FILES["files"]["name"][$source] && is_uploaded_file($_FILES["files"]["tmp_name"][$source])) {
+ if (isset($_FILES["files"]) && $_FILES["files"]["name"][$source] && is_uploaded_file($_FILES["files"]["tmp_name"][$source])) {
// Check for file upload errors and return FALSE if a
// lower level system error occurred.
@@ -253,7 +253,7 @@ function file_check_upload($source = 'upload') {
else {
// In case of previews return previous file object.
- if (file_exists($_SESSION['file_uploads'][$source]->filepath)) {
+ if (isset($_SESSION['file_uploads']) && file_exists($_SESSION['file_uploads'][$source]->filepath)) {
return $_SESSION['file_uploads'][$source];
}
}
diff --git a/includes/form.inc b/includes/form.inc
index b6647fdc4..49d8de0cf 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -265,7 +265,9 @@ function drupal_process_form($form_id, &$form) {
// We've finished calling functions that alter the global values, so we can
// restore the ones that were there before this function was called.
list($form_values, $form_submitted, $form_button_counter) = array_pop($saved_globals);
- return $redirect;
+ if (isset($redirect)) {
+ return $redirect;
+ }
}
/**
@@ -306,9 +308,7 @@ function drupal_prepare_form($form_id, &$form) {
// If $base is set, it is used in place of $form_id when constructing validation,
// submission, and theming functions. Useful for mapping many similar or duplicate
// forms with different $form_ids to the same processing functions.
- if (isset($form['#base'])) {
- $base = $form['#base'];
- }
+ $base = isset($form['#base']) ? $form['#base'] : '';
// Add a token, based on either #token or form_id, to any form displayed to
// authenticated users. This ensures that any submitted form was actually
@@ -432,7 +432,9 @@ function drupal_submit_form($form_id, $form) {
}
}
}
- return $goto;
+ if (isset($goto)) {
+ return $goto;
+ }
}
/**
@@ -450,9 +452,7 @@ function drupal_submit_form($form_id, $form) {
*/
function drupal_render_form($form_id, &$form) {
// Don't override #theme if someone already set it.
- if (isset($form['#base'])) {
- $base = $form['#base'];
- }
+ $base = isset($form['#base']) ? $form['#base'] : '';
if (!isset($form['#theme'])) {
if (theme_get_function($form_id)) {
@@ -492,16 +492,16 @@ function drupal_redirect_form($form, $redirect = NULL) {
if (isset($form['#redirect'])) {
$goto = $form['#redirect'];
}
- if ($goto !== FALSE) {
- if (is_array($goto)) {
- call_user_func_array('drupal_goto', $goto);
- }
- elseif (!isset($goto)) {
- drupal_goto($_GET['q']);
- }
- else {
- drupal_goto($goto);
+ if (!isset($goto) || ($goto !== FALSE)) {
+ if (isset($goto)) {
+ if (is_array($goto)) {
+ call_user_func_array('drupal_goto', $goto);
+ }
+ else {
+ drupal_goto($goto);
+ }
}
+ drupal_goto($_GET['q']);
}
}
@@ -756,7 +756,7 @@ function form_builder($form_id, $form) {
if (isset($form['#process']) && !$form['#processed']) {
foreach ($form['#process'] as $process => $args) {
if (function_exists($process)) {
- $args = array_merge(array($form), array($edit), $args);
+ $args = array_merge(array($form), array(isset($edit) ? $edit : NULL), $args);
$form = call_user_func_array($process, $args);
}
}
@@ -929,7 +929,7 @@ function theme_select($element) {
$select = '';
$size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
_form_set_class($element, array('form-select'));
- $multiple = isset($element['#multiple']) && $element['#multiple'];
+ $multiple = $element['#multiple'];
return theme('form_element', $element, '<select name="'. $element['#name'] .''. ($multiple ? '[]' : '') .'"'. ($multiple ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="'. $element['#id'] .'" '. $size .'>'. form_select_options($element) .'</select>');
}
@@ -1038,7 +1038,7 @@ function theme_fieldset($element) {
}
}
- return '<fieldset' . drupal_attributes($element['#attributes']) .'>' . ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . ($element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . $element['#children'] . $element['#value'] . "</fieldset>\n";
+ return '<fieldset' . drupal_attributes($element['#attributes']) .'>' . ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') . ($element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . $element['#value'] . "</fieldset>\n";
}
/**
@@ -1079,7 +1079,7 @@ function theme_radios($element) {
if (isset($element['#attributes']['class'])) {
$class .= ' '. $element['#attributes']['class'];
}
- $element['#children'] = '<div class="'. $class .'">'. $element['#children'] .'</div>';
+ $element['#children'] = '<div class="'. $class .'">'. (!empty($element['#children']) ? $element['#children'] : '') .'</div>';
if ($element['#title'] || $element['#description']) {
unset($element['#id']);
return theme('form_element', $element, $element['#children']);
@@ -1232,12 +1232,18 @@ function map_month($month) {
*/
function checkboxes_value(&$form) {
$value = array();
- foreach ((array)$form['#default_value'] as $key) {
+ $form += array('#default_value' => array());
+ foreach ($form['#default_value'] as $key) {
$value[$key] = 1;
}
$form['#value'] = $value;
}
+function password_confirm_value(&$form) {
+ $form += array('#default_value' => array());
+ $form['#value'] = $form['#default_value'] + array('pass1' => '', 'pass2' => '');
+}
+
/**
* If no default value is set for weight select boxes, use 0.
*/
@@ -1275,7 +1281,7 @@ function expand_radios($element) {
* A themed HTML string representing the form item.
*/
function theme_item($element) {
- return theme('form_element', $element, $element['#value'] . $element['#children']);
+ return theme('form_element', $element, $element['#value'] . (!empty($element['#children']) ? $element['#children'] : ''));
}
/**
@@ -1318,7 +1324,7 @@ function theme_checkboxes($element) {
if (isset($element['#attributes']['class'])) {
$class .= ' '. $element['#attributes']['class'];
}
- $element['#children'] = '<div class="'. $class .'">'. $element['#children'] .'</div>';
+ $element['#children'] = '<div class="'. $class .'">'. (!empty($element['#children']) ? $element['#children'] : '') .'</div>';
if ($element['#title'] || $element['#description']) {
unset($element['#id']);
return theme('form_element', $element, $element['#children']);
@@ -1492,6 +1498,7 @@ function process_weight($element) {
$element['#options'] = $weights;
$element['#type'] = 'select';
$element['#is_weight'] = TRUE;
+ $element += _element_info('select');
return $element;
}
diff --git a/includes/menu.inc b/includes/menu.inc
index 8a5ac6d8c..2fee91a30 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -356,7 +356,7 @@ function _menu_tree($result = NULL, $depth = 0, $link = array('link' => '', 'has
list($remnant, $menu) = _menu_tree($result, $item->depth, $menu_link);
$tree .= theme('menu_tree', $link, $menu);
$link = $remnant;
- $remnant = '';
+ $remnant = array('link' => '', 'has_children' => FALSE);
}
elseif ($item->depth == $depth) {
$tree .= theme('menu_link', $link);
@@ -496,6 +496,7 @@ function menu_rebuild() {
'_has_children' => 0,
'title' => '',
'weight' => 0,
+ 'type' => MENU_NORMAL_ITEM,
);
$sort[$path] = ($item['_visible'] ? $depth : $number_parts) . sprintf('%05d', $item['weight']) . $item['title'];
unset($item);
@@ -527,11 +528,6 @@ function menu_rebuild() {
if (!isset($item['map callback']) && isset($item['map arguments'])) {
$item['map callback'] = 'menu_map';
}
- foreach (array('access', 'map', 'page') as $type) {
- if (isset($item["$type callback"]) && !isset($item["$type arguments"])) {
- $item["$type arguments"] = array();
- }
- }
if (is_bool($item['access callback'])) {
$item['access callback'] = intval($item['access callback']);
}
@@ -548,7 +544,15 @@ function menu_rebuild() {
$vancode = '';
$link = '';
}
- db_query("INSERT INTO {menu} (mid, pid, path, access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, number_parts, vancode, menu_link, visible, parents, depth, has_children) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d)", $item['_mid'], $item['_pid'], $path, $item['access callback'], serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['map callback'], serialize($item['map arguments']), $item['_fit'], $item['_number_parts'], $vancode .'+', $link, $item['_visible'], $item['_parents'], $item['_depth'], $item['_has_children']);
+ $insert_item = $item + array(
+ 'access arguments' => array(),
+ 'access callback' => '',
+ 'page arguments' => array(),
+ 'page callback' => '',
+ 'map arguments' => array(),
+ 'map callback' => '',
+ );
+ db_query("INSERT INTO {menu} (mid, pid, path, access_callback, access_arguments, page_callback, page_arguments, map_callback, map_arguments, fit, number_parts, vancode, menu_link, visible, parents, depth, has_children) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d)", $insert_item['_mid'], $insert_item['_pid'], $path, $insert_item['access callback'], serialize($insert_item['access arguments']), $insert_item['page callback'], serialize($insert_item['page arguments']), $insert_item['map callback'], serialize($insert_item['map arguments']), $insert_item['_fit'], $insert_item['_number_parts'], $vancode .'+', $link, $insert_item['_visible'], $insert_item['_parents'], $insert_item['_depth'], $insert_item['_has_children']);
// $item needs to be unset because of the reference above.
unset($item);
}
diff --git a/includes/module.inc b/includes/module.inc
index 44aba1874..9f16cc7e1 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -127,7 +127,9 @@ function module_rebuild_cache() {
}
else {
// This is a new module.
- db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->info['description'], 'module', $file->filename, $file->status, $file->throttle, $bootstrap);
+ $files[$filename]->status = 0;
+ $files[$filename]->throttle = 0;
+ db_query("INSERT INTO {system} (name, description, type, filename, status, throttle, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d, %d)", $file->name, $file->info['description'], 'module', $file->filename, 0, 0, $bootstrap);
}
}
$files = _module_build_dependents($files);
diff --git a/includes/tablesort.inc b/includes/tablesort.inc
index f976eb512..48a445828 100644
--- a/includes/tablesort.inc
+++ b/includes/tablesort.inc
@@ -107,7 +107,7 @@ function tablesort_header($cell, $header, $ts) {
* A properly formatted cell, ready for _theme_table_cell().
*/
function tablesort_cell($cell, $header, $ts, $i) {
- if (isset($header[$i]) && $header[$i]['data'] == $ts['name'] && $header[$i]['field']) {
+ if (isset($header[$i]['data']) && $header[$i]['data'] == $ts['name'] && !empty($header[$i]['field'])) {
if (is_array($cell)) {
if (isset($cell['class'])) {
$cell['class'] .= ' active';
@@ -162,6 +162,7 @@ function tablesort_get_order($headers) {
else {
// The first column specified is initial 'order by' field unless otherwise specified
if (is_array($headers[0])) {
+ $headers[0] += array('data' => NULL, 'field' => NULL);
return array('name' => $headers[0]['data'], 'sql' => $headers[0]['field']);
}
else {
diff --git a/includes/theme.inc b/includes/theme.inc
index a5aab93ea..a829b2cca 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -42,7 +42,7 @@ function init_theme() {
// Only select the user selected theme if it is available in the
// list of enabled themes.
- $theme = $user->theme && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
+ $theme = !empty($user->theme) && $themes[$user->theme]->status ? $user->theme : variable_get('theme_default', 'garland');
// Allow modules to override the present theme... only select custom theme
// if it is available in the list of installed themes.
@@ -611,7 +611,7 @@ function theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize
if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
$attributes = drupal_attributes($attributes);
$url = (url($path) == $path) ? $path : (base_path() . $path);
- return '<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
+ return '<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. (isset($image_attributes) ? $image_attributes : '') . $attributes .' />';
}
}
@@ -1089,7 +1089,7 @@ function _theme_table_cell($cell, $header = FALSE) {
$attributes = '';
if (is_array($cell)) {
- $data = $cell['data'];
+ $data = isset($cell['data']) ? $cell['data'] : '';
$header |= isset($cell['header']);
unset($cell['data']);
unset($cell['header']);
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 9f2712990..ca9b693fb 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -300,7 +300,9 @@ function aggregator_block($op = 'list', $delta = 0, $edit = array()) {
$block['content'] = theme('item_list', $items) . $read_more;
}
}
- return $block;
+ if (isset($block)) {
+ return $block;
+ }
}
}
@@ -1102,7 +1104,9 @@ function _aggregator_page_list($sql, $op, $header = '') {
}
$output .= '</div>';
$output .= $form['pager']['#value'];
- $output .= $form['feed_icon']['#value'];
+ if (isset($form['feed_icon']['#value'])) {
+ $output .= $form['feed_icon']['#value'];
+ }
return $output;
}
}
diff --git a/modules/block/block.module b/modules/block/block.module
index e7936fef9..d0311a206 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -160,7 +160,7 @@ function _block_rehash() {
$block['module'] = $module;
$block['delta'] = $delta;
// If previously written to database, load values.
- if ($old_blocks[$module][$delta]) {
+ if (!empty($old_blocks[$module][$delta])) {
$block['status'] = $old_blocks[$module][$delta]->status;
$block['weight'] = $old_blocks[$module][$delta]->weight;
$block['region'] = $old_blocks[$module][$delta]->region;
@@ -310,7 +310,7 @@ function theme_block_admin_display($form) {
foreach (element_children($form) as $i) {
$block = &$form[$i];
// Only take form elements that are blocks.
- if (is_array($block['info'])) {
+ if (isset($block['info'])) {
// Fetch values
$region = $block['region']['#default_value'];
$status = $region != BLOCK_REGION_NONE;
@@ -337,7 +337,7 @@ function theme_block_admin_display($form) {
$row[] = drupal_render($block['throttle']);
}
$row[] = drupal_render($block['configure']);
- $row[] = $block['delete'] ? drupal_render($block['delete']) : '';
+ $row[] = !empty($block['delete']) ? drupal_render($block['delete']) : '';
$rows[] = $row;
}
}
@@ -624,14 +624,14 @@ function block_user($type, $edit, &$user, $category = NULL) {
}
}
- if ($return) {
+ if (!empty($return)) {
return $form;
}
}
break;
case 'validate':
- if (!$edit['block']) {
+ if (empty($edit['block'])) {
$edit['block'] = array();
}
return $edit;
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index d3e4a49c8..5b853ddbe 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -185,7 +185,7 @@ function blog_page_last() {
*/
function blog_form(&$node) {
global $nid;
- $iid = $_GET['iid'];
+ $iid = isset($_GET['iid']) ? (int)$_GET['iid'] : 0;
$type = node_get_types('type', $node);
@@ -207,8 +207,8 @@ function blog_form(&$node) {
}
- $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5);
- $form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
+ $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#required' => TRUE, '#default_value' => !empty($node->title) ? $node->title : NULL, '#weight' => -5);
+ $form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => !empty($node->body) ? $node->title : NULL, '#rows' => 20, '#required' => TRUE);
$form['body_filter']['filter'] = filter_form($node->format);
return $form;
}
diff --git a/modules/book/book.module b/modules/book/book.module
index 8216d617a..d1913bc2e 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -445,7 +445,7 @@ function book_nodeapi(&$node, $op, $teaser, $page) {
break;
case 'update':
if (isset($node->parent)) {
- if ($node->revision) {
+ if (!empty($node->revision)) {
db_query("INSERT INTO {book} (nid, vid, parent, weight) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->parent, $node->weight);
}
else {
@@ -507,7 +507,7 @@ function theme_book_navigation($node) {
* This is a helper function for book_toc().
*/
function book_toc_recurse($nid, $indent, $toc, $children, $exclude) {
- if ($children[$nid]) {
+ if (!empty($children[$nid])) {
foreach ($children[$nid] as $foo => $node) {
if (!$exclude || $exclude != $node->nid) {
$toc[$node->nid] = $indent .' '. $node->title;
@@ -527,7 +527,7 @@ function book_toc($exclude = 0) {
$children = array();
while ($node = db_fetch_object($result)) {
- if (!$children[$node->parent]) {
+ if (empty($children[$node->parent])) {
$children[$node->parent] = array();
}
$children[$node->parent][] = $node;
@@ -958,6 +958,7 @@ function book_admin($nid = 0) {
*/
function book_admin_overview() {
$result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE b.parent = 0 ORDER BY b.weight, n.title'));
+ $rows = array();
while ($book = db_fetch_object($result)) {
$rows[] = array(l($book->title, "node/$book->nid"), l(t('outline'), "admin/content/book/$book->nid"));
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 8e7a2e937..f92467c4a 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -791,6 +791,7 @@ function comment_save($edit) {
$edit['name'] = $user->name;
}
+ $edit += array('mail' => '', 'homepage' => '');
db_query("INSERT INTO {comments} (cid, nid, pid, uid, subject, comment, format, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, %d, '%s', '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit['cid'], $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], $_SERVER['REMOTE_ADDR'], $edit['timestamp'], $status, $score, $users, $thread, $edit['name'], $edit['mail'], $edit['homepage']);
_comment_update_node_statistics($edit['nid']);
@@ -1150,7 +1151,7 @@ function comment_operations($action = NULL) {
function comment_admin($type = 'new') {
$edit = $_POST;
- if ($edit['operation'] == 'delete' && $edit['comments']) {
+ if (isset($edit['operation']) && ($edit['operation'] == 'delete') && $edit['comments']) {
return drupal_get_form('comment_multiple_delete_confirm');
}
else {
@@ -1192,7 +1193,7 @@ function comment_admin_overview($type = 'new', $arg) {
$form['timestamp'][$comment->cid] = array('#value' => format_date($comment->timestamp, 'small'));
$form['operations'][$comment->cid] = array('#value' => l(t('edit'), 'comment/edit/'. $comment->cid, array(), $destination));
}
- $form['comments'] = array('#type' => 'checkboxes', '#options' => $comments);
+ $form['comments'] = array('#type' => 'checkboxes', '#options' => isset($comments) ? $comments: array());
$form['pager'] = array('#value' => theme('pager', NULL, 50, 0));
return $form;
}
@@ -1431,7 +1432,7 @@ function comment_form($edit, $title = NULL) {
$op = isset($_POST['op']) ? $_POST['op'] : '';
if ($user->uid) {
- if ($edit['cid'] && user_access('administer comments')) {
+ if (!empty($edit['cid']) && user_access('administer comments')) {
if ($edit['author']) {
$author = $edit['author'];
}
@@ -1537,19 +1538,19 @@ function comment_form($edit, $title = NULL) {
}
if (variable_get('comment_subject_field', 1) == 1) {
- $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $edit['subject']);
+ $form['subject'] = array('#type' => 'textfield', '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => !empty($edit['subject']) ? $edit['subject'] : '');
}
- $form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE);
+ $form['comment_filter']['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => !empty($edit['comment']) ? $edit['comment'] : $user->signature, '#required' => TRUE);
if (!isset($edit['format'])) {
$edit['format'] = FILTER_FORMAT_DEFAULT;
}
$form['comment_filter']['format'] = filter_form($edit['format']);
- $form['cid'] = array('#type' => 'value', '#value' => $edit['cid']);
+ $form['cid'] = array('#type' => 'value', '#value' => !empty($edit['cid']) ? $edit['cid'] : NULL);
$form['pid'] = array('#type' => 'value', '#value' => $edit['pid']);
$form['nid'] = array('#type' => 'value', '#value' => $edit['nid']);
- $form['uid'] = array('#type' => 'value', '#value' => $edit['uid']);
+ $form['uid'] = array('#type' => 'value', '#value' => !empty($edit['uid']) ? $edit['uid'] : NULL);
$form['preview'] = array('#type' => 'button', '#value' => t('Preview comment'), '#weight' => 19);
$form['#token'] = 'comment'. $edit['nid'] . $edit['pid'];
@@ -1565,7 +1566,7 @@ function comment_form($edit, $title = NULL) {
$form['#after_build'] = array('comment_form_add_preview');
}
- if ($_REQUEST['destination']) {
+ if (!empty($_REQUEST['destination'])) {
$form['#attributes']['destination'] = $_REQUEST['destination'];
}
@@ -1603,7 +1604,7 @@ function comment_form_add_preview($form, $edit) {
$comment->uid = $account->uid;
$comment->name = check_plain($account->name);
}
- $comment->timestamp = $edit['timestamp'] ? $edit['timestamp'] : time();
+ $comment->timestamp = !empty($edit['timestamp']) ? $edit['timestamp'] : time();
// Preview the comment with security check.
if (!form_get_errors()) {
diff --git a/modules/contact/contact.module b/modules/contact/contact.module
index 7dcc0e894..909b90e6f 100644
--- a/modules/contact/contact.module
+++ b/modules/contact/contact.module
@@ -116,7 +116,7 @@ function contact_user($type, &$edit, &$user, $category = NULL) {
);
$form['contact']['contact'] = array('#type' => 'checkbox',
'#title' => t('Personal contact form'),
- '#default_value' => $edit['contact'],
+ '#default_value' => !empty($edit['contact']) ? $edit['contact'] : FALSE,
'#description' => t('Allow other users to contact you by e-mail via <a href="@url">your personal contact form</a>. Note that while your e-mail address is not made public to other members of the community, privileged users such as site administrators are able to contact you even if you choose not to enable this feature.', array('@url' => url("user/$user->uid/contact"))),
);
return $form;
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 0892b5541..83fa3ba74 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -507,12 +507,11 @@ function filter_admin_format_form_submit($form_id, $form_values) {
cache_clear_all($format .':', 'cache_filter', TRUE);
// If a new filter was added, return to the main list of filters. Otherwise, stay on edit filter page to show new changes.
- if ($new) {
- return 'admin/settings/filters/';
- }
- else {
- return 'admin/settings/filters/'. $format;
+ $return = 'admin/settings/filters';
+ if (!empty($new)) {
+ $return .= '/'. $format;
}
+ return $return;
}
/**
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 23cab35e8..de845a837 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -388,16 +388,16 @@ function forum_update($node) {
*/
function forum_form(&$node) {
$type = node_get_types('type', $node);
- $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#default_value' => $node->title, '#required' => TRUE, '#weight' => -5);
+ $form['title'] = array('#type' => 'textfield', '#title' => check_plain($type->title_label), '#default_value' => !empty($node->title) ? $node->title : '', '#required' => TRUE, '#weight' => -5);
- if ($node->nid) {
+ if (!empty($node->nid)) {
$forum_terms = taxonomy_node_get_terms_by_vocabulary(_forum_get_vid(), $node->nid);
// if editing, give option to leave shadows
$shadow = (count($forum_terms) > 1);
$form['shadow'] = array('#type' => 'checkbox', '#title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.'));
}
- $form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
+ $form['body_filter']['body'] = array('#type' => 'textarea', '#title' => check_plain($type->body_label), '#default_value' => !empty($node->body) ? $node->body : '', '#rows' => 20, '#required' => TRUE);
$form['body_filter']['format'] = filter_form($node->format);
return $form;
@@ -407,7 +407,7 @@ function forum_form(&$node) {
* Implementation of hook_prepare; assign forum taxonomy when adding a topic from within a forum.
*/
function forum_prepare(&$node) {
- if (!$node->nid) {
+ if (empty($node->nid)) {
// new topic
$node->taxonomy[arg(3)]->vid = _forum_get_vid();
$node->taxonomy[arg(3)]->tid = arg(3);
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 7b22ca5c4..dd4c88093 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -240,7 +240,7 @@ function locale_supported_languages($reset = FALSE, $getall = FALSE) {
unset($enabled); unset($all);
}
- if (is_null($enabled)) {
+ if (!isset($enabled)) {
$enabled = $all = array();
$all['name'] = $all['formula'] = $enabled['name'] = $enabled['formula'] = array();
$result = db_query('SELECT locale, name, formula, enabled FROM {locales_meta} ORDER BY isdefault DESC, enabled DESC, name ASC');
diff --git a/modules/node/node.module b/modules/node/node.module
index d136bde84..e560f79ec 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -41,7 +41,7 @@ function node_help($section) {
if (arg(0) == 'node' && arg(1) == 'add' && $type = arg(2)) {
$type = node_get_types('type', str_replace('-', '_', arg(2)));
- return '<p>'. filter_xss_admin($type->help) .'</p>';
+ return '<p>'. (isset($type->help) ? filter_xss_admin($type->help) : '') .'</p>';
}
}
@@ -564,7 +564,7 @@ function node_save(&$node) {
}
$node = $node_current;
- if ($node->revision) {
+ if (!empty($node->revision)) {
$node->old_vid = $node->vid;
$node->vid = db_next_id('{node_revisions}_vid');
}
@@ -617,7 +617,7 @@ function node_save(&$node) {
}
$node_table_values[] = $node->nid;
$node_query = 'UPDATE {node} SET '. implode(', ', $arr) .' WHERE nid = %d';
- if ($node->revision) {
+ if (!empty($node->revision)) {
$revisions_query = 'INSERT INTO {node_revisions} ('. implode(', ', array_keys($revisions_table_types)) .') VALUES ('. implode(', ', $revisions_table_types) .')';
}
else {
@@ -1393,6 +1393,7 @@ function node_filter_form() {
* Theme node administration filter form.
*/
function theme_node_filter_form($form) {
+ $output = '';
$output .= '<div id="node-admin-filter">';
$output .= drupal_render($form['filters']);
$output .= '</div>';
@@ -1404,14 +1405,15 @@ function theme_node_filter_form($form) {
* Theme node administration filter selector.
*/
function theme_node_filters($form) {
+ $output = '';
$output .= '<ul class="clear-block">';
- if (sizeof($form['current'])) {
+ if (!empty($form['current'])) {
foreach (element_children($form['current']) as $key) {
$output .= '<li>'. drupal_render($form['current'][$key]) .'</li>';
}
}
- $output .= '<li><dl class="multiselect">'. (sizeof($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">';
+ $output .= '<li><dl class="multiselect">'. (!empty($form['current']) ? '<dt><em>'. t('and') .'</em> '. t('where') .'</dt>' : '') .'<dd class="a">';
foreach (element_children($form['filter']) as $key) {
$output .= drupal_render($form['filter'][$key]);
}
@@ -1495,7 +1497,7 @@ function node_admin_nodes_validate($form_id, $form_values) {
function node_admin_content() {
$output = drupal_get_form('node_filter_form');
- if ($_POST['operation'] == 'delete' && $_POST['nodes']) {
+ if (isset($_POST['operation']) && ($_POST['operation'] == 'delete') && $_POST['nodes']) {
return drupal_get_form('node_multiple_delete_confirm');
}
// Call the form first, to allow for the form_values array to be populated.
@@ -1542,6 +1544,7 @@ function node_admin_nodes() {
function theme_node_admin_nodes($form) {
// Overview table:
$header = array(theme('table_select_header_cell'), t('Title'), t('Type'), t('Author'), t('Status'), t('Operations'));
+ $output = '';
$output .= drupal_render($form['options']);
if (isset($form['title']) && is_array($form['title'])) {
@@ -1720,7 +1723,8 @@ function node_revision_list($node) {
}
function node_admin_search() {
- return drupal_get_form('search_form', url('admin/content/search'), $_POST['keys'], 'node') . search_data($_POST['keys'], 'node');
+ $keys = isset($_POST['keys']) ? $_POST['keys'] : NULL;
+ return drupal_get_form('search_form', url('admin/content/search'), $keys, 'node') . search_data($keys, 'node');
}
/**
@@ -1889,7 +1893,7 @@ function node_validate($node, $form = array()) {
// Make sure the body has the minimum number of words.
// todo use a better word counting algorithm that will work in other languages
- if (isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
+ if (!empty($type->min_word_count) && isset($node->body) && count(explode(' ', $node->body)) < $type->min_word_count) {
form_set_error('body', t('The body of your @type is too short. You need at least %words words.', array('%words' => $type->min_word_count, '@type' => $type->name)));
}
@@ -1953,12 +1957,14 @@ function node_form($node, $form_values = NULL) {
* These elements are just values so they are not even sent to the client.
*/
foreach (array('nid', 'vid', 'uid', 'created', 'type') as $key) {
- $form[$key] = array('#type' => 'value', '#value' => $node->$key);
+ $form[$key] = array('#type' => 'value', '#value' => isset($node->$key) ? $node->$key : NULL);
}
// Changed must be sent to the client, for later overwrite error checking.
- $form['changed'] = array('#type' => 'hidden', '#default_value' => $node->changed);
-
+ $form['changed'] = array('#type' => 'hidden', '#default_value' => isset($node->changed) ? $node->changed : NULL);
+ if (!isset($node->format)) {
+ $node->format = NULL;
+ }
// Get the node-specific bits.
$form = array_merge_recursive($form, node_invoke($node, 'form', $form_values));
if (!isset($form['title']['#weight'])) {
@@ -2029,7 +2035,7 @@ function node_form($node, $form_values = NULL) {
// Add the buttons.
$form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 40);
$form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 45);
- if ($node->nid && node_access('delete', $node)) {
+ if (!empty($node->nid) && node_access('delete', $node)) {
$form['delete'] = array('#type' => 'button', '#value' => t('Delete'), '#weight' => 50);
}
$form['#after_build'] = array('node_form_add_preview');
@@ -2388,7 +2394,7 @@ function node_page_view($node, $cid = NULL) {
* Menu callback; presents the node editing form, or redirects to delete confirmation.
*/
function node_page_edit($node) {
- if ($_POST['op'] == t('Delete')) {
+ if (isset($_POST['op']) && ($_POST['op'] == t('Delete'))) {
// Note: we redirect from node/nid/edit to node/nid/delete to make the tabs disappear.
if ($_REQUEST['destination']) {
$destination = drupal_get_destination();
diff --git a/modules/path/path.module b/modules/path/path.module
index b52f47254..7c6b5480b 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -244,7 +244,7 @@ function path_nodeapi(&$node, $op, $arg) {
break;
case 'update':
- path_set_alias("node/$node->nid", $node->path, $node->pid);
+ path_set_alias("node/$node->nid", isset($node->path) ? $node->path : NULL, isset($node->pid) ? $node->pid : NULL);
break;
case 'delete':
@@ -262,7 +262,7 @@ function path_nodeapi(&$node, $op, $arg) {
*/
function path_form_alter($form_id, &$form) {
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
- $path = $form['#node']->path;
+ $path = isset($form['#node']->path) ? $form['#node']->path : NULL;
$form['path'] = array(
'#type' => 'fieldset',
'#title' => t('URL path settings'),
@@ -309,12 +309,13 @@ function path_overview() {
$sql .= tablesort_sql($header);
$result = pager_query($sql, 50);
+ $rows = array();
$destination = drupal_get_destination();
while ($data = db_fetch_object($result)) {
$rows[] = array(check_plain($data->dst), check_plain($data->src), l(t('edit'), "admin/build/path/edit/$data->pid", array(), $destination), l(t('delete'), "admin/build/path/delete/$data->pid", array(), $destination));
}
- if (!$rows) {
+ if (empty($rows)) {
$rows[] = array(array('data' => t('No URL aliases available.'), 'colspan' => '4'));
}
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
index 51f3512ab..4883e383c 100644
--- a/modules/profile/profile.module
+++ b/modules/profile/profile.module
@@ -596,6 +596,7 @@ function profile_view_profile($user) {
$result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d ORDER BY category, weight', PROFILE_PRIVATE, PROFILE_HIDDEN);
}
+ $fields = array();
while ($field = db_fetch_object($result)) {
if ($value = profile_view_field($user, $field)) {
$title = ($field->type != 'checkbox') ? check_plain($field->title) : NULL;
@@ -626,6 +627,7 @@ function _profile_form_explanation($field) {
function profile_form_profile($edit, $user, $category, $register = FALSE) {
$result = _profile_get_fields($category, $register);
$w = 0;
+ $fields = array();
while ($field = db_fetch_object($result)) {
$category = $field->category;
if (!isset($fields[$category])) {
@@ -744,6 +746,7 @@ function profile_validate_profile($edit, $category) {
function profile_categories() {
$result = db_query("SELECT DISTINCT(category) FROM {profile_fields}");
+ $data = array();
while ($category = db_fetch_object($result)) {
$data[] = array('name' => $category->category, 'title' => $category->category, 'weight' => 3);
}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 23c29efcd..2aeed3ba5 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -257,6 +257,7 @@ function statistics_recent_hits() {
$sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid' . tablesort_sql($header);
$result = pager_query($sql, 30);
+ $rows = array();
while ($log = db_fetch_object($result)) {
$rows[] = array(
array('data' => format_date($log->timestamp, 'small'), 'class' => 'nowrap'),
@@ -286,6 +287,7 @@ function statistics_top_pages() {
$sql .= tablesort_sql($header);
$result = pager_query($sql, 30, 0, $sql_cnt);
+ $rows = array();
while ($page = db_fetch_object($result)) {
$rows[] = array($page->hits, _statistics_format_item($page->title, $page->path), t('%time ms', array('%time' => round($page->average_time))), format_interval(round($page->total_time / 1000)));
}
@@ -312,6 +314,7 @@ function statistics_top_visitors() {
$sql_cnt = "SELECT COUNT(DISTINCT(CONCAT(uid, hostname))) FROM {accesslog}";
$result = pager_query($sql, 30, 0, $sql_cnt);
+ $rows = array();
while ($account = db_fetch_object($result)) {
$qs = drupal_get_destination();
$ban_link = $account->aid ? l(t('unban'), "admin/user/rules/delete/$account->aid", array(), $qs) : l(t('ban'), "admin/user/rules/add/$account->hostname/host", array(), $qs);
@@ -341,6 +344,7 @@ function statistics_top_referrers() {
$query .= tablesort_sql($header);
$result = pager_query($query, 30, 0, $query_cnt, $_SERVER['HTTP_HOST']);
+ $rows = array();
while ($referrer = db_fetch_object($result)) {
$rows[] = array($referrer->hits, _statistics_link($referrer->url), t('@time ago', array('@time' => format_interval(time() - $referrer->last))));
}
@@ -452,8 +456,9 @@ function statistics_block($op = 'list', $delta = 0, $edit = array()) {
case 'list':
if (variable_get('statistics_count_content_views', 0)) {
$blocks[0]['info'] = t('Popular content');
+ return $blocks;
}
- return $blocks;
+ break;
case 'configure':
// Popular content block settings
diff --git a/modules/system/system.install b/modules/system/system.install
index 3f9b89b77..bf65b3fea 100644
--- a/modules/system/system.install
+++ b/modules/system/system.install
@@ -3,7 +3,7 @@
define('DRUPAL_MINIMUM_PHP', '4.3.3');
define('DRUPAL_MINIMUM_MYSQL', '4.1.0'); // If using MySQL
-define('DRUPAL_MINIMUM_PGSQL', '7.3'); // If using PostgreSQL
+define('DRUPAL_MINIMUM_PGSQL', '7.4'); // If using PostgreSQL
define('DRUPAL_MINIMUM_APACHE', '1.3'); // If using Apache
/**
diff --git a/modules/system/system.module b/modules/system/system.module
index b78919f5c..d105fd212 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -62,23 +62,23 @@ function system_elements() {
$type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE);
$type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE);
$type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
- $type['password'] = array('#input' => TRUE, '#size' => 60);
+ $type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128);
$type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm' => array()));
- $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5);
+ $type['textarea'] = array('#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => TRUE);
$type['radios'] = array('#input' => TRUE, '#process' => array('expand_radios' => array()));
- $type['radio'] = array('#input' => TRUE);
+ $type['radio'] = array('#input' => TRUE, '#default_value' => NULL);
$type['checkboxes'] = array('#input' => TRUE, '#process' => array('expand_checkboxes' => array()), '#tree' => TRUE);
- $type['select'] = array('#input' => TRUE);
+ $type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE);
$type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight' => array()));
$type['date'] = array('#input' => TRUE, '#process' => array('expand_date' => array()), '#validate' => array('date_validate' => array()));
$type['file'] = array('#input' => TRUE, '#size' => 60);
// Form structure
- $type['item'] = array();
+ $type['item'] = array('#value' => '');
$type['hidden'] = array('#input' => TRUE);
$type['value'] = array('#input' => TRUE);
$type['markup'] = array('#prefix' => '', '#suffix' => '');
- $type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE);
+ $type['fieldset'] = array('#collapsible' => FALSE, '#collapsed' => FALSE, '#value' => NULL);
$type['token'] = array('#input' => TRUE);
return $type;
}
@@ -309,7 +309,7 @@ function system_init() {
*/
function system_user($type, $edit, &$user, $category = NULL) {
if ($type == 'form' && $category == 'account') {
- $form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), $edit['theme'], 2);
+ $form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), isset($edit['theme']) ? $edit['theme'] : NULL, 2);
if (variable_get('configurable_timezones', 1)) {
$zones = _system_zonelist();
@@ -496,7 +496,7 @@ function system_theme_select_form($description = '', $default_value = '', $weigh
function theme_system_theme_select_form($form) {
foreach (element_children($form) as $key) {
$row = array();
- if (is_array($form[$key]['description'])) {
+ if (isset($form[$key]['description']) && is_array($form[$key]['description'])) {
$row[] = drupal_render($form[$key]['screenshot']);
$row[] = drupal_render($form[$key]['description']);
$row[] = drupal_render($form['theme'][$key]);
@@ -949,7 +949,7 @@ function system_theme_data() {
$style->template = isset($theme->template) ? $theme->template : FALSE;
$style->name = basename(dirname($style->filename));
$style->owner = $theme->filename;
- $style->prefix = $theme->template ? $theme->prefix : $theme->name;
+ $style->prefix = !empty($theme->template) ? $theme->prefix : $theme->name;
// do not double-insert styles with theme files in their directory
if (array_key_exists($style->name, $themes)) {
continue;
@@ -1160,7 +1160,7 @@ function system_themes() {
function theme_system_themes($form) {
foreach (element_children($form) as $key) {
$row = array();
- if (is_array($form[$key]['description'])) {
+ if (isset($form[$key]['description']) && is_array($form[$key]['description'])) {
$row[] = drupal_render($form[$key]['screenshot']);
$row[] = drupal_render($form[$key]['description']);
$row[] = array('data' => drupal_render($form['status'][$key]), 'align' => 'center');
@@ -1242,8 +1242,13 @@ function system_modules($form_values = NULL) {
// Array for disabling checkboxes in callback system_module_disable.
$disabled = array();
+ $throttle = array();
// Traverse the files retrieved and build the form.
foreach ($files as $filename => $file) {
+ $file->info += array(
+ 'dependents' => array(),
+ 'version' => NULL,
+ );
$form['name'][$filename] = array('#value' => $file->info['name']);
$form['version'][$filename] = array('#value' => $file->info['version']);
$form['description'][$filename] = array('#value' => t($file->info['description']));
@@ -1286,16 +1291,14 @@ function system_modules($form_values = NULL) {
// Mark dependents disabled so user can not remove modules being depended on.
$dependents = array();
- if (is_array($file->info['dependents'])) {
- foreach ($file->info['dependents'] as $dependent) {
- if ($files[$dependent]->status == 1) {
- $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
- $disabled[] = $filename;
- $form['disabled_modules']['#value'][$filename] = TRUE;
- }
- else {
- $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
- }
+ foreach ($file->info['dependents'] as $dependent) {
+ if ($files[$dependent]->status == 1) {
+ $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-enabled">enabled</span>)');
+ $disabled[] = $filename;
+ $form['disabled_modules']['#value'][$filename] = TRUE;
+ }
+ else {
+ $dependents[] = $files[$dependent]->info['name'] . t(' (<span class="admin-disabled">disabled</span>)');
}
}
@@ -1602,7 +1605,7 @@ function system_modules_uninstall($form_values = NULL) {
}
// Only build the rest of the form if there are any modules available to uninstall.
- if (count($options)) {
+ if (!empty($options)) {
$form['uninstall'] = array(
'#type' => 'checkboxes',
'#options' => $options,
@@ -1614,6 +1617,9 @@ function system_modules_uninstall($form_values = NULL) {
$form['#multistep'] = TRUE;
$form['#action'] = url('admin/build/modules/uninstall/confirm');
}
+ else {
+ $form['modules'] = array();
+ }
return $form;
}
@@ -1688,7 +1694,7 @@ function theme_system_modules_uninstall($form) {
}
// Only display table if there are modules that can be uninstalled.
- if (!count($rows)) {
+ if (empty($rows)) {
$rows[] = array(array('data' => t('No modules are available to uninstall.'), 'colspan' => '3', 'align' => 'center', 'class' => 'message'));
}
@@ -1845,7 +1851,7 @@ function theme_status_report(&$requirements) {
$i = 0;
$output = '<table class="system-status-report">';
foreach ($requirements as $requirement) {
- if ($requirement['#type'] == '') {
+ if (empty($requirement['#type'])) {
$class = ++$i % 2 == 0 ? 'even' : 'odd';
$classes = array(
@@ -1854,10 +1860,10 @@ function theme_status_report(&$requirements) {
REQUIREMENT_WARNING => 'warning',
REQUIREMENT_ERROR => 'error',
);
- $class = $classes[(int)$requirement['severity']] .' '. $class;
+ $class = $classes[isset($requirement['severity']) ? (int)$requirement['severity'] : 0] .' '. $class;
// Output table row(s)
- if ($requirement['description']) {
+ if (empty($requirement['description'])) {
$output .= '<tr class="'. $class .' merge-down"><th>'. $requirement['title'] .'</th><td>'. $requirement['value'] .'</td></tr>';
$output .= '<tr class="'. $class .' merge-up"><td colspan="2">'. $requirement['description'] .'</td></tr>';
}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 6df04ac84..ed05eb8bb 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -296,7 +296,7 @@ function taxonomy_form_vocabulary_submit($form_id, $form_values) {
function taxonomy_save_vocabulary(&$edit) {
$edit['nodes'] = empty($edit['nodes']) ? array() : $edit['nodes'];
- if ($edit['vid'] && $edit['name']) {
+ if (!empty($edit['vid']) && !empty($edit['name'])) {
db_query("UPDATE {vocabulary} SET name = '%s', description = '%s', help = '%s', multiple = %d, required = %d, hierarchy = %d, relations = %d, tags = %d, weight = %d, module = '%s' WHERE vid = %d", $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy', $edit['vid']);
db_query("DELETE FROM {vocabulary_node_types} WHERE vid = %d", $edit['vid']);
foreach ($edit['nodes'] as $type => $selected) {
@@ -305,12 +305,12 @@ function taxonomy_save_vocabulary(&$edit) {
module_invoke_all('taxonomy', 'update', 'vocabulary', $edit);
$status = SAVED_UPDATED;
}
- else if ($edit['vid']) {
+ else if (!empty($edit['vid'])) {
$status = taxonomy_del_vocabulary($edit['vid']);
}
else {
$edit['vid'] = db_next_id('{vocabulary}_vid');
- db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['vid'], $edit['name'], $edit['description'], $edit['help'], $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], $edit['tags'], $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy');
+ db_query("INSERT INTO {vocabulary} (vid, name, description, help, multiple, required, hierarchy, relations, tags, weight, module) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, %d, %d, %d, '%s')", $edit['vid'], $edit['name'], isset($edit['description']) ? $edit['description'] : NULL, isset($edit['help']) ? $edit['help'] : NULL, $edit['multiple'], $edit['required'], $edit['hierarchy'], $edit['relations'], isset($edit['tags']) ? $edit['tags'] : NULL, $edit['weight'], isset($edit['module']) ? $edit['module'] : 'taxonomy');
foreach ($edit['nodes'] as $type => $selected) {
db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type);
}
@@ -657,12 +657,7 @@ function taxonomy_form_alter($form_id, &$form) {
$node = $form['#node'];
if (!isset($node->taxonomy)) {
- if ($node->nid) {
- $terms = taxonomy_node_get_terms($node->nid);
- }
- else {
- $terms = array();
- }
+ $terms = empty($node->nid) ? array() : taxonomy_node_get_terms($node->nid);
}
else {
$terms = $node->taxonomy;
@@ -716,7 +711,7 @@ function taxonomy_form_alter($form_id, &$form) {
$form['taxonomy'][$vocabulary->vid]['#required'] = $vocabulary->required;
}
}
- if (is_array($form['taxonomy']) && !empty($form['taxonomy'])) {
+ if (!empty($form['taxonomy']) && is_array($form['taxonomy'])) {
if (count($form['taxonomy']) > 1) { // Add fieldset only if form has more than 1 element.
$form['taxonomy'] += array(
'#type' => 'fieldset',
@@ -768,7 +763,7 @@ function taxonomy_node_validate(&$node) {
if ($terms['tags']) {
foreach ($terms['tags'] as $vid => $vid_value) {
$vocabulary = taxonomy_get_vocabulary($vid);
- if (!$vocabulary->tags) {
+ if (empty($vocabulary->tags)) {
// see form_get_error $key = implode('][', $element['#parents']);
// on why this is the key
form_set_error("taxonomy][tags][$vid", t('The %name vocabulary can not be modified in this way.', array('%name' => $vocabulary->name)));
@@ -976,7 +971,8 @@ function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
}
$max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
- if ($children[$vid][$parent]) {
+ $tree = array();
+ if (!empty($children[$vid][$parent])) {
foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
$term = drupal_clone($terms[$vid][$child]);
@@ -986,14 +982,14 @@ function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
$term->parents = $parents[$vid][$child];
$tree[] = $term;
- if ($children[$vid][$child]) {
+ if (!empty($children[$vid][$child])) {
$tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
}
}
}
}
- return $tree ? $tree : array();
+ return $tree;
}
/**
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 5fec76209..c85df433c 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -285,7 +285,7 @@ function _upload_prepare(&$node) {
// Clean up old file previews if a post didn't get the user to this page.
// i.e. the user left the edit page, because they didn't want to upload anything.
if(count($_POST) == 0) {
- if (is_array($_SESSION['file_previews']) && count($_SESSION['file_previews'])) {
+ if (!empty($_SESSION['file_previews']) && is_array($_SESSION['file_previews'])) {
foreach ($_SESSION['file_previews'] as $fid => $file) {
file_delete($file->filepath);
}
@@ -321,7 +321,7 @@ function _upload_prepare(&$node) {
}
// Attach file previews to node object.
- if (is_array($_SESSION['file_previews']) && count($_SESSION['file_previews'])) {
+ if (!empty($_SESSION['file_previews']) && is_array($_SESSION['file_previews'])) {
foreach ($_SESSION['file_previews'] as $fid => $file) {
if ($user->uid != 1) {
// Here something.php.pps becomes something.php_.pps
@@ -395,7 +395,7 @@ function _upload_validate(&$node) {
$filesize = 0;
// Check if node->files exists, and if it contains something.
- if (is_array($node->files)) {
+ if (isset($node->files) && is_array($node->files)) {
// Update existing files with form data.
foreach ($node->files as $fid => $file) {
// Convert file to object for compatibility
@@ -762,7 +762,7 @@ function _upload_form($node) {
$form['#theme'] = 'upload_form_new';
- if (is_array($node->files) && count($node->files)) {
+ if (!empty($node->files) && is_array($node->files)) {
$form['files']['#theme'] = 'upload_form_current';
$form['files']['#tree'] = TRUE;
foreach ($node->files as $key => $file) {
@@ -799,7 +799,7 @@ function _upload_form($node) {
}
// Needed for JS
- $form['current']['vid'] = array('#type' => 'hidden', '#value' => $node->vid);
+ $form['current']['vid'] = array('#type' => 'hidden', '#value' => isset($node->vid) ? $node->vid : 0);
return $form;
}
diff --git a/modules/user/user.module b/modules/user/user.module
index d2ed6208d..3bab8cd3a 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -113,7 +113,7 @@ function user_save($account, $array = array(), $category = 'account') {
$user_fields = user_fields();
if ($account->uid) {
user_module_invoke('update', $array, $account, $category);
-
+ $query = '';
$data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid)));
foreach ($array as $key => $value) {
if ($key == 'pass' && !empty($value)) {
@@ -143,7 +143,7 @@ function user_save($account, $array = array(), $category = 'account') {
db_query("UPDATE {users} SET $query WHERE uid = %d", array_merge($v, array($account->uid)));
// Reload user roles if provided
- if (is_array($array['roles'])) {
+ if (isset($array['roles']) && is_array($array['roles'])) {
db_query('DELETE FROM {users_roles} WHERE uid = %d', $account->uid);
foreach (array_keys($array['roles']) as $rid) {
@@ -708,8 +708,8 @@ function user_view_access($account) {
);
}
-function user_edit_access($uid) {
- return ($GLOBALS['user']->uid == $uid) || array('administer users');
+function user_edit_access($account) {
+ return ($GLOBALS['user']->uid == $account->uid) || array('administer users');
}
function user_load_self($arg) {
@@ -909,7 +909,8 @@ function user_menu() {
'type' => MENU_LOCAL_TASK,
);
- if (($categories = _user_categories($account)) && (count($categories) > 1)) {
+ $empty_account = new stdClass();
+ if (($categories = _user_categories($empty_account)) && (count($categories) > 1)) {
foreach ($categories as $key => $category) {
$items['user/%/edit/'. $category['name']] = array(
'title' => $category['title'],
@@ -1479,7 +1480,7 @@ function _user_edit_validate($uid, &$edit) {
function _user_edit_submit($uid, &$edit) {
$user = user_load(array('uid' => $uid));
// Delete picture if requested, and if no replacement picture was given.
- if ($edit['picture_delete']) {
+ if (!empty($edit['picture_delete'])) {
if ($user->picture && file_exists($user->picture)) {
file_delete($user->picture);
}
@@ -1498,7 +1499,8 @@ function user_edit($category = 'account') {
drupal_set_message(t('The account does not exist or has already been deleted.'));
drupal_goto('admin/user/user');
}
- $edit = $_POST['op'] ? $_POST : (array)$account;
+ $op = !empty($_POST['op']) ? $_POST['op'] : '';
+ $edit = $op ? $_POST : (array)$account;
if (arg(2) == 'delete') {
if ($edit['confirm']) {
@@ -1509,7 +1511,7 @@ function user_edit($category = 'account') {
return drupal_get_form('user_confirm_delete', $account->name, $account->uid);
}
}
- else if ($_POST['op'] == t('Delete')) {
+ else if ($op == t('Delete')) {
if ($_REQUEST['destination']) {
$destination = drupal_get_destination();
unset($_REQUEST['destination']);
@@ -1820,7 +1822,7 @@ function user_admin_access() {
while ($rule = db_fetch_object($result)) {
$rows[] = array($rule->status ? t('allow') : t('deny'), $access_types[$rule->type], $rule->mask, l(t('edit'), 'admin/user/rules/edit/'. $rule->aid), l(t('delete'), 'admin/user/rules/delete/'. $rule->aid));
}
- if (count($rows) == 0) {
+ if (empty($rows)) {
$rows[] = array(array('data' => '<em>'. t('There are currently no access rules.') .'</em>', 'colspan' => 5));
}
$output .= theme('table', $header, $rows);
@@ -2068,7 +2070,7 @@ function theme_user_admin_new_role($form) {
$rows[] = array($name, t('locked'), $edit_permissions);
}
}
- $rows[] = array(drupal_render($form['name']), array('data' => drupal_render($form['submit']), colspan => 2));
+ $rows[] = array(drupal_render($form['name']), array('data' => drupal_render($form['submit']), 'colspan' => 2));
$output = drupal_render($form);
$output .= theme('table', $header, $rows);
@@ -2410,14 +2412,15 @@ function user_admin($callback_arg = '') {
switch ($op) {
case 'search':
case t('Search'):
- $output = drupal_get_form('search_form', url('admin/user/search'), $_POST['keys'], 'user') . search_data($_POST['keys'], 'user');
+ $keys = isset($_POST['keys']) ? $_POST['keys'] : NULL;
+ $output = drupal_get_form('search_form', url('admin/user/search'), $keys, 'user') . search_data($keys, 'user');
break;
case t('Create new account'):
case 'create':
$output = drupal_get_form('user_register');
break;
default:
- if ($_POST['accounts'] && $_POST['operation'] == 'delete') {
+ if (!empty($_POST['accounts']) && isset($_POST['operation']) && ($_POST['operation'] == 'delete')) {
$output = drupal_get_form('user_multiple_delete_confirm');
}
else {
@@ -2510,6 +2513,8 @@ function _user_categories($account) {
}
function _user_sort($a, $b) {
+ $a = (array)$a + array('weight' => 0, 'title' => '');
+ $b = (array)$b + array('weight' => 0, 'title' => '');
return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
}
@@ -2677,7 +2682,7 @@ function theme_user_filter_form($form) {
*/
function theme_user_filters($form) {
$output = '<ul class="clear-block">';
- if (sizeof($form['current'])) {
+ if (!empty($form['current'])) {
foreach (element_children($form['current']) as $key) {
$output .= '<li>'. drupal_render($form['current'][$key]) .'</li>';
}
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index 39784a0bf..e26f48a64 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -174,11 +174,12 @@ function watchdog_top($type) {
$result = pager_query("SELECT COUNT(wid) AS count, message FROM {watchdog} WHERE type = '%s' GROUP BY message ". tablesort_sql($header), 30, 0, "SELECT COUNT(DISTINCT(message)) FROM {watchdog} WHERE type = '%s'", $type);
+ $rows = array();
while ($watchdog = db_fetch_object($result)) {
$rows[] = array($watchdog->count, truncate_utf8($watchdog->message, 56, TRUE, TRUE));
}
- if (!$rows) {
+ if (empty($rows)) {
$rows[] = array(array('data' => t('No log messages available.'), 'colspan' => 2));
}
diff --git a/sites/default/settings.php b/sites/default/settings.php
index a6cbd050b..08c5513c4 100644
--- a/sites/default/settings.php
+++ b/sites/default/settings.php
@@ -90,7 +90,7 @@
* $db_url = 'mysqli://username:password@localhost/databasename';
* $db_url = 'pgsql://username:password@localhost/databasename';
*/
-$db_url = 'mysql://username:password@localhost/databasename';
+$db_url = 'mysql://drupal:drupal@localhost/drupal';
$db_prefix = '';
/**
diff --git a/themes/bluemarine/comment.tpl.php b/themes/bluemarine/comment.tpl.php
index 1cee35cba..02eee299c 100644
--- a/themes/bluemarine/comment.tpl.php
+++ b/themes/bluemarine/comment.tpl.php
@@ -1,4 +1,4 @@
- <div class="comment<?php if ($comment->status == COMMENT_NOT_PUBLISHED) print ' comment-unpublished'; ?>">
+ <div class="comment<?php if (isset($comment->status) && $comment->status == COMMENT_NOT_PUBLISHED) print ' comment-unpublished'; ?>">
<?php if ($picture) {
print $picture;
} ?>
diff --git a/themes/garland/comment.tpl.php b/themes/garland/comment.tpl.php
index 6d3fb73c6..30c5ff937 100644
--- a/themes/garland/comment.tpl.php
+++ b/themes/garland/comment.tpl.php
@@ -1,4 +1,4 @@
-<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print ($comment->status == COMMENT_NOT_PUBLISHED) ? ' comment-unpublished' : ''; print ' '. $zebra; ?>">
+<div class="comment<?php print ($comment->new) ? ' comment-new' : ''; print (isset($comment->status) && $comment->status == COMMENT_NOT_PUBLISHED) ? ' comment-unpublished' : ''; print ' '. $zebra; ?>">
<div class="clear-block">
<?php if ($submitted): ?>