Commit f6764cfb authored by Dries's avatar Dries

- Patch #30930 by m3avrck/deekayen: cured PHP5 warnings.

parent 07ecb2ab
...@@ -858,7 +858,7 @@ function update_150() { ...@@ -858,7 +858,7 @@ function update_150() {
$ret[] = update_sql('DROP TABLE {search_index}'); $ret[] = update_sql('DROP TABLE {search_index}');
$ret[] = update_sql('DROP TABLE {search_total}'); $ret[] = update_sql('DROP TABLE {search_total}');
switch ($GLOBALS['db_type']) { switch ($GLOBALS['db_type']) {
case 'mysqli': case 'mysqli':
case 'mysql': case 'mysql':
......
...@@ -148,14 +148,14 @@ function conf_init() { ...@@ -148,14 +148,14 @@ function conf_init() {
function drupal_get_filename($type, $name, $filename = NULL) { function drupal_get_filename($type, $name, $filename = NULL) {
static $files = array(); static $files = array();
if (!$files[$type]) { if (!isset($files[$type])) {
$files[$type] = array(); $files[$type] = array();
} }
if ($filename && file_exists($filename)) { if (!empty($filename) && file_exists($filename)) {
$files[$type][$name] = $filename; $files[$type][$name] = $filename;
} }
elseif ($files[$type][$name]) { elseif (isset($files[$type][$name])) {
// nothing // nothing
} }
elseif (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file)) { 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) { ...@@ -722,7 +722,7 @@ function check_url($uri) {
/** /**
* Since request_uri() is only available on Apache, we generate an * Since request_uri() is only available on Apache, we generate an
* equivalent using other environment vars. * equivalent using other environment variables.
*/ */
function request_uri() { function request_uri() {
...@@ -788,7 +788,8 @@ function drupal_set_message($message = NULL, $type = 'status') { ...@@ -788,7 +788,8 @@ function drupal_set_message($message = NULL, $type = 'status') {
$_SESSION['messages'][$type][] = $message; $_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) { ...@@ -867,7 +868,7 @@ function _drupal_bootstrap($phase) {
// deny access to hosts which were banned. t() is not yet available. // deny access to hosts which were banned. t() is not yet available.
if (drupal_is_denied('host', $_SERVER['REMOTE_ADDR'])) { if (drupal_is_denied('host', $_SERVER['REMOTE_ADDR'])) {
header('HTTP/1.0 403 Forbidden'); header('HTTP/1.0 403 Forbidden');
print "Sorry, ". $_SERVER['REMOTE_ADDR']. " has been banned."; print 'Sorry, '. $_SERVER['REMOTE_ADDR']. ' has been banned.';
exit(); exit();
} }
......
...@@ -53,10 +53,8 @@ function drupal_set_content($region = null, $data = null) { ...@@ -53,10 +53,8 @@ function drupal_set_content($region = null, $data = null) {
*/ */
function drupal_get_content($region = null, $delimiter = ' ') { function drupal_get_content($region = null, $delimiter = ' ') {
$content = drupal_set_content(); $content = drupal_set_content();
if (isset($region)) { if (isset($region) && isset($content[$region]) && is_array($content[$region])) {
if (is_array($content[$region])) {
return implode ($delimiter, $content[$region]); return implode ($delimiter, $content[$region]);
}
} }
else { else {
foreach (array_keys($content) as $region) { foreach (array_keys($content) as $region) {
...@@ -78,7 +76,7 @@ function drupal_get_content($region = null, $delimiter = ' ') { ...@@ -78,7 +76,7 @@ function drupal_get_content($region = null, $delimiter = ' ') {
function drupal_set_breadcrumb($breadcrumb = NULL) { function drupal_set_breadcrumb($breadcrumb = NULL) {
static $stored_breadcrumb; static $stored_breadcrumb;
if (isset($breadcrumb)) { if (!is_null($breadcrumb)) {
$stored_breadcrumb = $breadcrumb; $stored_breadcrumb = $breadcrumb;
} }
return $stored_breadcrumb; return $stored_breadcrumb;
...@@ -90,7 +88,7 @@ function drupal_set_breadcrumb($breadcrumb = NULL) { ...@@ -90,7 +88,7 @@ function drupal_set_breadcrumb($breadcrumb = NULL) {
function drupal_get_breadcrumb() { function drupal_get_breadcrumb() {
$breadcrumb = drupal_set_breadcrumb(); $breadcrumb = drupal_set_breadcrumb();
if (!isset($breadcrumb)) { if (is_null($breadcrumb)) {
$breadcrumb = menu_get_active_breadcrumb(); $breadcrumb = menu_get_active_breadcrumb();
} }
...@@ -569,7 +567,7 @@ function locale_initialize() { ...@@ -569,7 +567,7 @@ function locale_initialize() {
// Useful for e.g. XML/HTML 'lang' attributes. // Useful for e.g. XML/HTML 'lang' attributes.
$languages = array('en' => 'English'); $languages = array('en' => 'English');
} }
if ($user->uid && $languages[$user->language]) { if ($user->uid && isset($languages[$user->language])) {
return $user->language; return $user->language;
} }
else { else {
...@@ -1298,7 +1296,7 @@ function drupal_implode_autocomplete($array) { ...@@ -1298,7 +1296,7 @@ function drupal_implode_autocomplete($array) {
/** /**
* Wrapper around urlencode() which avoids Apache quirks. * 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 * @param $text
* String to encode * String to encode
......
...@@ -125,7 +125,8 @@ function image_scale($source, $destination, $width, $height) { ...@@ -125,7 +125,8 @@ function image_scale($source, $destination, $width, $height) {
if ($aspect < $height / $width) { if ($aspect < $height / $width) {
$width = (int)min($width, $info['width']); $width = (int)min($width, $info['width']);
$height = (int)round($width * $aspect); $height = (int)round($width * $aspect);
} else { }
else {
$height = (int)min($height, $info['height']); $height = (int)min($height, $info['height']);
$width = (int)round($height / $aspect); $width = (int)round($height / $aspect);
} }
......
...@@ -742,7 +742,18 @@ function _menu_sort($a, $b) { ...@@ -742,7 +742,18 @@ function _menu_sort($a, $b) {
$a = &$menu['items'][$a]; $a = &$menu['items'][$a];
$b = &$menu['items'][$b]; $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;
}
} }
/** /**
......
...@@ -50,13 +50,13 @@ ...@@ -50,13 +50,13 @@
*/ */
function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
global $pager_page_array, $pager_total, $pager_total_items; global $pager_page_array, $pager_total, $pager_total_items;
$page = $_GET['page']; $page = isset($_GET['page']) ? $_GET['page'] : '';
// Substitute in query arguments. // Substitute in query arguments.
$args = func_get_args(); $args = func_get_args();
$args = array_slice($args, 4); $args = array_slice($args, 4);
// Alternative syntax for '...' // Alternative syntax for '...'
if (is_array($args[0])) { if (isset($args[0]) && is_array($args[0])) {
$args = $args[0]; $args = $args[0];
} }
...@@ -72,13 +72,13 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { ...@@ -72,13 +72,13 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
if (count($args)) { if (count($args)) {
$pager_total_items[$element] = db_result(db_query($count_query, $args)); $pager_total_items[$element] = db_result(db_query($count_query, $args));
$pager_total[$element] = ceil($pager_total_items[$element] / $limit); $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); return db_query_range($query, $args, $pager_page_array[$element] * $limit, $limit);
} }
else { else {
$pager_total_items[$element] = db_result(db_query($count_query)); $pager_total_items[$element] = db_result(db_query($count_query));
$pager_total[$element] = ceil($pager_total_items[$element] / $limit); $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); return db_query_range($query, $pager_page_array[$element] * $limit, $limit);
} }
} }
......
...@@ -316,7 +316,9 @@ function theme_get_setting($setting_name, $refresh = FALSE) { ...@@ -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. // 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 = 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']) { if ($settings['toggle_' . $type . '_links']) {
for ($i =0; $i < $count; $i++) { for ($i =0; $i < $count; $i++) {
......
...@@ -232,11 +232,13 @@ function xmlrpc_message_tag_close($parser, $tag) { ...@@ -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') { if ($xmlrpc_message->array_structs_types[count($xmlrpc_message->array_structs_types)-1] == 'struct') {
// Add to 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; $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 // Add to array
$xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][] = $value; $xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][] = $value;
} }
} else { }
else {
// Just add as a paramater // Just add as a paramater
$xmlrpc_message->params[] = $value; $xmlrpc_message->params[] = $value;
} }
......
...@@ -124,7 +124,8 @@ function xmlrpc_server_multicall($methodcalls) { ...@@ -124,7 +124,8 @@ function xmlrpc_server_multicall($methodcalls) {
$params = $call['params']; $params = $call['params'];
if ($method == 'system.multicall') { if ($method == 'system.multicall') {
$result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden')); $result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden'));
} else { }
else {
$result = xmlrpc_server_call($xmlrpc_server, $method, $params); $result = xmlrpc_server_call($xmlrpc_server, $method, $params);
} }
if ($result->is_error) { if ($result->is_error) {
...@@ -132,7 +133,8 @@ function xmlrpc_server_multicall($methodcalls) { ...@@ -132,7 +133,8 @@ function xmlrpc_server_multicall($methodcalls) {
'faultCode' => $result->code, 'faultCode' => $result->code,
'faultString' => $result->message 'faultString' => $result->message
); );
} else { }
else {
$return[] = $result; $return[] = $result;
} }
} }
......
...@@ -125,7 +125,7 @@ function redirectFormButton(uri, button, handler) { ...@@ -125,7 +125,7 @@ function redirectFormButton(uri, button, handler) {
// Trap the button // Trap the button
button.onfocus = function() { button.onfocus = function() {
button.onclick = function() { button.onclick = function() {
// Prepare vars for use in anonymous function. // Prepare variables for use in anonymous function.
var button = this; var button = this;
var action = button.form.action; var action = button.form.action;
var target = button.form.target; var target = button.form.target;
......
...@@ -96,6 +96,8 @@ function block_menu($may_cache) { ...@@ -96,6 +96,8 @@ function block_menu($may_cache) {
function block_block($op = 'list', $delta = 0, $edit = array()) { function block_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) { switch ($op) {
case 'list': case 'list':
$blocks = array();
$result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title'); $result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title');
while ($block = db_fetch_object($result)) { while ($block = db_fetch_object($result)) {
$blocks[$block->bid]['info'] = $block->info ? check_plain($block->info) : check_plain($block->title); $blocks[$block->bid]['info'] = $block->info ? check_plain($block->info) : check_plain($block->title);
...@@ -455,8 +457,8 @@ function block_box_save($edit, $delta = NULL) { ...@@ -455,8 +457,8 @@ function block_box_save($edit, $delta = NULL) {
* Menu callback; displays the block overview page. * Menu callback; displays the block overview page.
*/ */
function block_admin() { function block_admin() {
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
if ($op == t('Save blocks')) { if ($op == t('Save blocks')) {
block_admin_save($edit); block_admin_save($edit);
...@@ -526,7 +528,7 @@ function block_list($region) { ...@@ -526,7 +528,7 @@ function block_list($region) {
if (!count($blocks)) { if (!count($blocks)) {
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key); $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key);
while ($block = db_fetch_object($result)) { while ($block = db_fetch_object($result)) {
if(!isset($blocks[$block->region])) { if (!isset($blocks[$block->region])) {
$blocks[$block->region] = array(); $blocks[$block->region] = array();
} }
// Use the user's block visibility setting, if necessary // Use the user's block visibility setting, if necessary
...@@ -574,7 +576,7 @@ function block_list($region) { ...@@ -574,7 +576,7 @@ function block_list($region) {
} }
} }
// Create an empty array if there were no entries // Create an empty array if there were no entries
if(!isset($blocks[$region])) { if (!isset($blocks[$region])) {
$blocks[$region] = array(); $blocks[$region] = array();
} }
return $blocks[$region]; return $blocks[$region];
......
...@@ -96,6 +96,8 @@ function block_menu($may_cache) { ...@@ -96,6 +96,8 @@ function block_menu($may_cache) {
function block_block($op = 'list', $delta = 0, $edit = array()) { function block_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) { switch ($op) {
case 'list': case 'list':
$blocks = array();
$result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title'); $result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title');
while ($block = db_fetch_object($result)) { while ($block = db_fetch_object($result)) {
$blocks[$block->bid]['info'] = $block->info ? check_plain($block->info) : check_plain($block->title); $blocks[$block->bid]['info'] = $block->info ? check_plain($block->info) : check_plain($block->title);
...@@ -455,8 +457,8 @@ function block_box_save($edit, $delta = NULL) { ...@@ -455,8 +457,8 @@ function block_box_save($edit, $delta = NULL) {
* Menu callback; displays the block overview page. * Menu callback; displays the block overview page.
*/ */
function block_admin() { function block_admin() {
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
if ($op == t('Save blocks')) { if ($op == t('Save blocks')) {
block_admin_save($edit); block_admin_save($edit);
...@@ -526,7 +528,7 @@ function block_list($region) { ...@@ -526,7 +528,7 @@ function block_list($region) {
if (!count($blocks)) { if (!count($blocks)) {
$result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key); $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s' AND status = 1 ORDER BY region, weight, module", $theme_key);
while ($block = db_fetch_object($result)) { while ($block = db_fetch_object($result)) {
if(!isset($blocks[$block->region])) { if (!isset($blocks[$block->region])) {
$blocks[$block->region] = array(); $blocks[$block->region] = array();
} }
// Use the user's block visibility setting, if necessary // Use the user's block visibility setting, if necessary
...@@ -574,7 +576,7 @@ function block_list($region) { ...@@ -574,7 +576,7 @@ function block_list($region) {
} }
} }
// Create an empty array if there were no entries // Create an empty array if there were no entries
if(!isset($blocks[$region])) { if (!isset($blocks[$region])) {
$blocks[$region] = array(); $blocks[$region] = array();
} }
return $blocks[$region]; return $blocks[$region];
......
...@@ -284,7 +284,7 @@ function filter_admin_overview() { ...@@ -284,7 +284,7 @@ function filter_admin_overview() {
$roles = array(); $roles = array();
foreach (user_roles() as $rid => $name) { foreach (user_roles() as $rid => $name) {
//prepare a roles array with roles that may access the filter //prepare a roles array with roles that may access the filter
if (strstr($format->roles, ",$rid,")){ if (strstr($format->roles, ",$rid,")) {
$roles[] = $name; $roles[] = $name;
} }
} }
......
...@@ -284,7 +284,7 @@ function filter_admin_overview() { ...@@ -284,7 +284,7 @@ function filter_admin_overview() {
$roles = array(); $roles = array();
foreach (user_roles() as $rid => $name) { foreach (user_roles() as $rid => $name) {
//prepare a roles array with roles that may access the filter //prepare a roles array with roles that may access the filter
if (strstr($format->roles, ",$rid,")){ if (strstr($format->roles, ",$rid,")) {
$roles[] = $name; $roles[] = $name;
} }
} }
......
...@@ -99,8 +99,8 @@ function menu_nodeapi(&$node, $op) { ...@@ -99,8 +99,8 @@ function menu_nodeapi(&$node, $op) {
if (user_access('administer menu')) { if (user_access('administer menu')) {
switch ($op) { switch ($op) {
case 'form': case 'form':
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$edit['nid'] = $node->nid; $edit['nid'] = isset($node->nid) ? $node->nid : '';
return menu_node_form($edit); return menu_node_form($edit);
break; break;
...@@ -145,7 +145,7 @@ function menu_overview() { ...@@ -145,7 +145,7 @@ function menu_overview() {
* Menu callback; clear the database, resetting the menu to factory defaults. * Menu callback; clear the database, resetting the menu to factory defaults.
*/ */
function menu_reset() { function menu_reset() {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) { switch ($op) {
case t('Reset all'): case t('Reset all'):
db_query('DELETE FROM {menu}'); db_query('DELETE FROM {menu}');
...@@ -164,8 +164,8 @@ function menu_reset() { ...@@ -164,8 +164,8 @@ function menu_reset() {
* Menu callback; handle the adding of a new menu. * Menu callback; handle the adding of a new menu.
*/ */
function menu_add_menu() { function menu_add_menu() {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = ''; $output = '';
switch ($op) { switch ($op) {
...@@ -189,7 +189,7 @@ function menu_add_menu() { ...@@ -189,7 +189,7 @@ function menu_add_menu() {
* Menu callback; reset a single modified item. * Menu callback; reset a single modified item.
*/ */
function menu_reset_item($mid) { function menu_reset_item($mid) {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) { switch ($op) {
case t('Reset'): case t('Reset'):
db_query('DELETE FROM {menu} WHERE mid = %d', $mid); db_query('DELETE FROM {menu} WHERE mid = %d', $mid);
...@@ -209,7 +209,7 @@ function menu_reset_item($mid) { ...@@ -209,7 +209,7 @@ function menu_reset_item($mid) {
* Menu callback; delete a single custom item. * Menu callback; delete a single custom item.
*/ */
function menu_delete_item($mid) { function menu_delete_item($mid) {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
$result = db_query('SELECT type, title FROM {menu} WHERE mid = %d', $mid); $result = db_query('SELECT type, title FROM {menu} WHERE mid = %d', $mid);
$menu = db_fetch_object($result); $menu = db_fetch_object($result);
if (!$menu) { if (!$menu) {
...@@ -255,8 +255,8 @@ function menu_disable_item($mid) { ...@@ -255,8 +255,8 @@ function menu_disable_item($mid) {
* Menu callback; dispatch to the appropriate menu item edit function. * Menu callback; dispatch to the appropriate menu item edit function.
*/ */
function menu_edit_item($mid = 0) { function menu_edit_item($mid = 0) {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = ''; $output = '';
...@@ -419,7 +419,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) { ...@@ -419,7 +419,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$rows = array(); $rows = array();
if (isset($menu['items'][$pid]) && $menu['items'][$pid]['children']) { if (isset($menu['items'][$pid]) && isset($menu['items'][$pid]['children'])) {
usort($menu['items'][$pid]['children'], '_menu_sort'); usort($menu['items'][$pid]['children'], '_menu_sort');
foreach ($menu['items'][$pid]['children'] as $mid) { foreach ($menu['items'][$pid]['children'] as $mid) {
......
...@@ -99,8 +99,8 @@ function menu_nodeapi(&$node, $op) { ...@@ -99,8 +99,8 @@ function menu_nodeapi(&$node, $op) {
if (user_access('administer menu')) { if (user_access('administer menu')) {
switch ($op) { switch ($op) {
case 'form': case 'form':
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$edit['nid'] = $node->nid; $edit['nid'] = isset($node->nid) ? $node->nid : '';
return menu_node_form($edit); return menu_node_form($edit);
break; break;
...@@ -145,7 +145,7 @@ function menu_overview() { ...@@ -145,7 +145,7 @@ function menu_overview() {
* Menu callback; clear the database, resetting the menu to factory defaults. * Menu callback; clear the database, resetting the menu to factory defaults.
*/ */
function menu_reset() { function menu_reset() {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) { switch ($op) {
case t('Reset all'): case t('Reset all'):
db_query('DELETE FROM {menu}'); db_query('DELETE FROM {menu}');
...@@ -164,8 +164,8 @@ function menu_reset() { ...@@ -164,8 +164,8 @@ function menu_reset() {
* Menu callback; handle the adding of a new menu. * Menu callback; handle the adding of a new menu.
*/ */
function menu_add_menu() { function menu_add_menu() {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = ''; $output = '';
switch ($op) { switch ($op) {
...@@ -189,7 +189,7 @@ function menu_add_menu() { ...@@ -189,7 +189,7 @@ function menu_add_menu() {
* Menu callback; reset a single modified item. * Menu callback; reset a single modified item.
*/ */
function menu_reset_item($mid) { function menu_reset_item($mid) {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) { switch ($op) {
case t('Reset'): case t('Reset'):
db_query('DELETE FROM {menu} WHERE mid = %d', $mid); db_query('DELETE FROM {menu} WHERE mid = %d', $mid);
...@@ -209,7 +209,7 @@ function menu_reset_item($mid) { ...@@ -209,7 +209,7 @@ function menu_reset_item($mid) {
* Menu callback; delete a single custom item. * Menu callback; delete a single custom item.
*/ */
function menu_delete_item($mid) { function menu_delete_item($mid) {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
$result = db_query('SELECT type, title FROM {menu} WHERE mid = %d', $mid); $result = db_query('SELECT type, title FROM {menu} WHERE mid = %d', $mid);
$menu = db_fetch_object($result); $menu = db_fetch_object($result);
if (!$menu) { if (!$menu) {
...@@ -255,8 +255,8 @@ function menu_disable_item($mid) { ...@@ -255,8 +255,8 @@ function menu_disable_item($mid) {
* Menu callback; dispatch to the appropriate menu item edit function. * Menu callback; dispatch to the appropriate menu item edit function.
*/ */
function menu_edit_item($mid = 0) { function menu_edit_item($mid = 0) {
$op = $_POST['op']; $op = isset($_POST['op']) ? $_POST['op'] : '';
$edit = $_POST['edit']; $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = ''; $output = '';
...@@ -419,7 +419,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) { ...@@ -419,7 +419,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$rows = array(); $rows = array();
if (isset($menu['items'][$pid]) && $menu['items'][$pid]['children']) { if (isset($menu['items'][$pid]) && isset($menu['items'][$pid]['children'])) {
usort($menu['items'][$pid]['children'], '_menu_sort');