summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-10-22 15:14:46 +0000
committerDries Buytaert <dries@buytaert.net>2005-10-22 15:14:46 +0000
commitf6764cfbd8dcdedd05263711a41fcedb72dda2ab (patch)
tree88f659fea364fc50d3173da0c5a8bdbc28be8557
parent07ecb2abb0206484a77acbf5ba767af856d99520 (diff)
downloadbrdo-f6764cfbd8dcdedd05263711a41fcedb72dda2ab.tar.gz
brdo-f6764cfbd8dcdedd05263711a41fcedb72dda2ab.tar.bz2
- Patch #30930 by m3avrck/deekayen: cured PHP5 warnings.
-rw-r--r--database/updates.inc2
-rw-r--r--includes/bootstrap.inc13
-rw-r--r--includes/common.inc12
-rw-r--r--includes/image.inc3
-rw-r--r--includes/menu.inc13
-rw-r--r--includes/pager.inc8
-rw-r--r--includes/theme.inc4
-rw-r--r--includes/xmlrpc.inc6
-rw-r--r--includes/xmlrpcs.inc6
-rw-r--r--misc/drupal.js2
-rw-r--r--modules/block.module10
-rw-r--r--modules/block/block.module10
-rw-r--r--modules/filter.module2
-rw-r--r--modules/filter/filter.module2
-rw-r--r--modules/menu.module20
-rw-r--r--modules/menu/menu.module20
-rw-r--r--modules/node.module28
-rw-r--r--modules/node/node.module28
-rw-r--r--modules/search.module2
-rw-r--r--modules/search/search.module2
-rw-r--r--modules/system.module7
-rw-r--r--modules/system/system.module7
-rw-r--r--modules/user.module39
-rw-r--r--modules/user/user.module39
-rw-r--r--themes/engines/phptemplate/phptemplate.engine22
25 files changed, 166 insertions, 141 deletions
diff --git a/database/updates.inc b/database/updates.inc
index 2c2c57dea..4f7f32be7 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -858,7 +858,7 @@ function update_150() {
$ret[] = update_sql('DROP TABLE {search_index}');
$ret[] = update_sql('DROP TABLE {search_total}');
-
+
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 02618277f..5f72665cd 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -148,14 +148,14 @@ function conf_init() {
function drupal_get_filename($type, $name, $filename = NULL) {
static $files = array();
- if (!$files[$type]) {
+ if (!isset($files[$type])) {
$files[$type] = array();
}
- if ($filename && file_exists($filename)) {
+ if (!empty($filename) && file_exists($filename)) {
$files[$type][$name] = $filename;
}
- elseif ($files[$type][$name]) {
+ elseif (isset($files[$type][$name])) {
// nothing
}
elseif (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file)) {
@@ -722,7 +722,7 @@ function check_url($uri) {
/**
* Since request_uri() is only available on Apache, we generate an
- * equivalent using other environment vars.
+ * equivalent using other environment variables.
*/
function request_uri() {
@@ -788,7 +788,8 @@ function drupal_set_message($message = NULL, $type = 'status') {
$_SESSION['messages'][$type][] = $message;
}
- return $_SESSION['messages'];
+ // messages not set when DB connection fails
+ return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;
}
/**
@@ -867,7 +868,7 @@ function _drupal_bootstrap($phase) {
// deny access to hosts which were banned. t() is not yet available.
if (drupal_is_denied('host', $_SERVER['REMOTE_ADDR'])) {
header('HTTP/1.0 403 Forbidden');
- print "Sorry, ". $_SERVER['REMOTE_ADDR']. " has been banned.";
+ print 'Sorry, '. $_SERVER['REMOTE_ADDR']. ' has been banned.';
exit();
}
diff --git a/includes/common.inc b/includes/common.inc
index 953339300..f3e95a2fe 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -53,10 +53,8 @@ function drupal_set_content($region = null, $data = null) {
*/
function drupal_get_content($region = null, $delimiter = ' ') {
$content = drupal_set_content();
- if (isset($region)) {
- if (is_array($content[$region])) {
+ if (isset($region) && isset($content[$region]) && is_array($content[$region])) {
return implode ($delimiter, $content[$region]);
- }
}
else {
foreach (array_keys($content) as $region) {
@@ -78,7 +76,7 @@ function drupal_get_content($region = null, $delimiter = ' ') {
function drupal_set_breadcrumb($breadcrumb = NULL) {
static $stored_breadcrumb;
- if (isset($breadcrumb)) {
+ if (!is_null($breadcrumb)) {
$stored_breadcrumb = $breadcrumb;
}
return $stored_breadcrumb;
@@ -90,7 +88,7 @@ function drupal_set_breadcrumb($breadcrumb = NULL) {
function drupal_get_breadcrumb() {
$breadcrumb = drupal_set_breadcrumb();
- if (!isset($breadcrumb)) {
+ if (is_null($breadcrumb)) {
$breadcrumb = menu_get_active_breadcrumb();
}
@@ -569,7 +567,7 @@ function locale_initialize() {
// Useful for e.g. XML/HTML 'lang' attributes.
$languages = array('en' => 'English');
}
- if ($user->uid && $languages[$user->language]) {
+ if ($user->uid && isset($languages[$user->language])) {
return $user->language;
}
else {
@@ -1298,7 +1296,7 @@ function drupal_implode_autocomplete($array) {
/**
* Wrapper around urlencode() which avoids Apache quirks.
*
- * Should be used when placing arbitrary data inside the path of a clean URL.
+ * Should be used when placing arbitrary data inside the path of a clean URL.
*
* @param $text
* String to encode
diff --git a/includes/image.inc b/includes/image.inc
index 9dea8d52c..a4cf79b44 100644
--- a/includes/image.inc
+++ b/includes/image.inc
@@ -125,7 +125,8 @@ function image_scale($source, $destination, $width, $height) {
if ($aspect < $height / $width) {
$width = (int)min($width, $info['width']);
$height = (int)round($width * $aspect);
- } else {
+ }
+ else {
$height = (int)min($height, $info['height']);
$width = (int)round($height / $aspect);
}
diff --git a/includes/menu.inc b/includes/menu.inc
index 826d1c0ed..9fc2ab465 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -742,7 +742,18 @@ function _menu_sort($a, $b) {
$a = &$menu['items'][$a];
$b = &$menu['items'][$b];
- return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
+ if ($a['weight'] < $b['weight']) {
+ return -1;
+ }
+ elseif ($a['weight'] > $b['weight']) {
+ return 1;
+ }
+ elseif (isset($a['title']) && isset($b['title']) && ($a['title'] < $b['title'])) {
+ return -1;
+ }
+ else {
+ return 1;
+ }
}
/**
diff --git a/includes/pager.inc b/includes/pager.inc
index 959ce321b..58891986e 100644
--- a/includes/pager.inc
+++ b/includes/pager.inc
@@ -50,13 +50,13 @@
*/
function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
global $pager_page_array, $pager_total, $pager_total_items;
- $page = $_GET['page'];
+ $page = isset($_GET['page']) ? $_GET['page'] : '';
// Substitute in query arguments.
$args = func_get_args();
$args = array_slice($args, 4);
// Alternative syntax for '...'
- if (is_array($args[0])) {
+ if (isset($args[0]) && is_array($args[0])) {
$args = $args[0];
}
@@ -72,13 +72,13 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
if (count($args)) {
$pager_total_items[$element] = db_result(db_query($count_query, $args));
$pager_total[$element] = ceil($pager_total_items[$element] / $limit);
- $pager_page_array[$element] = max(0, min($pager_page_array[$element], ((int)$pager_total[$element]) - 1));
+ $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));
return db_query_range($query, $args, $pager_page_array[$element] * $limit, $limit);
}
else {
$pager_total_items[$element] = db_result(db_query($count_query));
$pager_total[$element] = ceil($pager_total_items[$element] / $limit);
- $pager_page_array[$element] = max(0, min($pager_page_array[$element], ((int)$pager_total[$element]) - 1));
+ $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1));
return db_query_range($query, $pager_page_array[$element] * $limit, $limit);
}
}
diff --git a/includes/theme.inc b/includes/theme.inc
index b90d6505e..f345be9dc 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -316,7 +316,9 @@ function theme_get_setting($setting_name, $refresh = FALSE) {
// Get the amount of links to show, possibly expanding if there are more links defined than the count specifies.
$count = variable_get($type . '_link_count', 5);
- $count = ($count > sizeof($value['link'])) ? $count : sizeof($value['link']);
+ if (isset($value['link']) && $count > sizeof($value['link'])) {
+ $count = sizeof($value['link']);
+ }
if ($settings['toggle_' . $type . '_links']) {
for ($i =0; $i < $count; $i++) {
diff --git a/includes/xmlrpc.inc b/includes/xmlrpc.inc
index 4ed533c6b..a31d53e11 100644
--- a/includes/xmlrpc.inc
+++ b/includes/xmlrpc.inc
@@ -232,11 +232,13 @@ function xmlrpc_message_tag_close($parser, $tag) {
if ($xmlrpc_message->array_structs_types[count($xmlrpc_message->array_structs_types)-1] == 'struct') {
// Add to struct
$xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][$xmlrpc_message->current_struct_name[count($xmlrpc_message->current_struct_name)-1]] = $value;
- } else {
+ }
+ else {
// Add to array
$xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][] = $value;
}
- } else {
+ }
+ else {
// Just add as a paramater
$xmlrpc_message->params[] = $value;
}
diff --git a/includes/xmlrpcs.inc b/includes/xmlrpcs.inc
index 26b004159..35acdeb95 100644
--- a/includes/xmlrpcs.inc
+++ b/includes/xmlrpcs.inc
@@ -124,7 +124,8 @@ function xmlrpc_server_multicall($methodcalls) {
$params = $call['params'];
if ($method == 'system.multicall') {
$result = xmlrpc_error(-32600, t('Recursive calls to system.multicall are forbidden'));
- } else {
+ }
+ else {
$result = xmlrpc_server_call($xmlrpc_server, $method, $params);
}
if ($result->is_error) {
@@ -132,7 +133,8 @@ function xmlrpc_server_multicall($methodcalls) {
'faultCode' => $result->code,
'faultString' => $result->message
);
- } else {
+ }
+ else {
$return[] = $result;
}
}
diff --git a/misc/drupal.js b/misc/drupal.js
index f685490c3..1ddde7516 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -125,7 +125,7 @@ function redirectFormButton(uri, button, handler) {
// Trap the button
button.onfocus = function() {
button.onclick = function() {
- // Prepare vars for use in anonymous function.
+ // Prepare variables for use in anonymous function.
var button = this;
var action = button.form.action;
var target = button.form.target;
diff --git a/modules/block.module b/modules/block.module
index 333920156..f94de166c 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -96,6 +96,8 @@ function block_menu($may_cache) {
function block_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
+ $blocks = array();
+
$result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title');
while ($block = db_fetch_object($result)) {
$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) {
* Menu callback; displays the block overview page.
*/
function block_admin() {
- $edit = $_POST['edit'];
- $op = $_POST['op'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
if ($op == t('Save blocks')) {
block_admin_save($edit);
@@ -526,7 +528,7 @@ function block_list($region) {
if (!count($blocks)) {
$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)) {
- if(!isset($blocks[$block->region])) {
+ if (!isset($blocks[$block->region])) {
$blocks[$block->region] = array();
}
// Use the user's block visibility setting, if necessary
@@ -574,7 +576,7 @@ function block_list($region) {
}
}
// Create an empty array if there were no entries
- if(!isset($blocks[$region])) {
+ if (!isset($blocks[$region])) {
$blocks[$region] = array();
}
return $blocks[$region];
diff --git a/modules/block/block.module b/modules/block/block.module
index 333920156..f94de166c 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -96,6 +96,8 @@ function block_menu($may_cache) {
function block_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
+ $blocks = array();
+
$result = db_query('SELECT bid, title, info FROM {boxes} ORDER BY title');
while ($block = db_fetch_object($result)) {
$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) {
* Menu callback; displays the block overview page.
*/
function block_admin() {
- $edit = $_POST['edit'];
- $op = $_POST['op'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
if ($op == t('Save blocks')) {
block_admin_save($edit);
@@ -526,7 +528,7 @@ function block_list($region) {
if (!count($blocks)) {
$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)) {
- if(!isset($blocks[$block->region])) {
+ if (!isset($blocks[$block->region])) {
$blocks[$block->region] = array();
}
// Use the user's block visibility setting, if necessary
@@ -574,7 +576,7 @@ function block_list($region) {
}
}
// Create an empty array if there were no entries
- if(!isset($blocks[$region])) {
+ if (!isset($blocks[$region])) {
$blocks[$region] = array();
}
return $blocks[$region];
diff --git a/modules/filter.module b/modules/filter.module
index 1c17624f0..dc98bf6d5 100644
--- a/modules/filter.module
+++ b/modules/filter.module
@@ -284,7 +284,7 @@ function filter_admin_overview() {
$roles = array();
foreach (user_roles() as $rid => $name) {
//prepare a roles array with roles that may access the filter
- if (strstr($format->roles, ",$rid,")){
+ if (strstr($format->roles, ",$rid,")) {
$roles[] = $name;
}
}
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 1c17624f0..dc98bf6d5 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -284,7 +284,7 @@ function filter_admin_overview() {
$roles = array();
foreach (user_roles() as $rid => $name) {
//prepare a roles array with roles that may access the filter
- if (strstr($format->roles, ",$rid,")){
+ if (strstr($format->roles, ",$rid,")) {
$roles[] = $name;
}
}
diff --git a/modules/menu.module b/modules/menu.module
index c15b77f42..ac7d10fbb 100644
--- a/modules/menu.module
+++ b/modules/menu.module
@@ -99,8 +99,8 @@ function menu_nodeapi(&$node, $op) {
if (user_access('administer menu')) {
switch ($op) {
case 'form':
- $edit = $_POST['edit'];
- $edit['nid'] = $node->nid;
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $edit['nid'] = isset($node->nid) ? $node->nid : '';
return menu_node_form($edit);
break;
@@ -145,7 +145,7 @@ function menu_overview() {
* Menu callback; clear the database, resetting the menu to factory defaults.
*/
function menu_reset() {
- $op = $_POST['op'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) {
case t('Reset all'):
db_query('DELETE FROM {menu}');
@@ -164,8 +164,8 @@ function menu_reset() {
* Menu callback; handle the adding of a new menu.
*/
function menu_add_menu() {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = '';
switch ($op) {
@@ -189,7 +189,7 @@ function menu_add_menu() {
* Menu callback; reset a single modified item.
*/
function menu_reset_item($mid) {
- $op = $_POST['op'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) {
case t('Reset'):
db_query('DELETE FROM {menu} WHERE mid = %d', $mid);
@@ -209,7 +209,7 @@ function menu_reset_item($mid) {
* Menu callback; delete a single custom item.
*/
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);
$menu = db_fetch_object($result);
if (!$menu) {
@@ -255,8 +255,8 @@ function menu_disable_item($mid) {
* Menu callback; dispatch to the appropriate menu item edit function.
*/
function menu_edit_item($mid = 0) {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = '';
@@ -419,7 +419,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$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');
foreach ($menu['items'][$pid]['children'] as $mid) {
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index c15b77f42..ac7d10fbb 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -99,8 +99,8 @@ function menu_nodeapi(&$node, $op) {
if (user_access('administer menu')) {
switch ($op) {
case 'form':
- $edit = $_POST['edit'];
- $edit['nid'] = $node->nid;
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $edit['nid'] = isset($node->nid) ? $node->nid : '';
return menu_node_form($edit);
break;
@@ -145,7 +145,7 @@ function menu_overview() {
* Menu callback; clear the database, resetting the menu to factory defaults.
*/
function menu_reset() {
- $op = $_POST['op'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) {
case t('Reset all'):
db_query('DELETE FROM {menu}');
@@ -164,8 +164,8 @@ function menu_reset() {
* Menu callback; handle the adding of a new menu.
*/
function menu_add_menu() {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = '';
switch ($op) {
@@ -189,7 +189,7 @@ function menu_add_menu() {
* Menu callback; reset a single modified item.
*/
function menu_reset_item($mid) {
- $op = $_POST['op'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
switch ($op) {
case t('Reset'):
db_query('DELETE FROM {menu} WHERE mid = %d', $mid);
@@ -209,7 +209,7 @@ function menu_reset_item($mid) {
* Menu callback; delete a single custom item.
*/
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);
$menu = db_fetch_object($result);
if (!$menu) {
@@ -255,8 +255,8 @@ function menu_disable_item($mid) {
* Menu callback; dispatch to the appropriate menu item edit function.
*/
function menu_edit_item($mid = 0) {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
$output = '';
@@ -419,7 +419,7 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
$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');
foreach ($menu['items'][$pid]['children'] as $mid) {
diff --git a/modules/node.module b/modules/node.module
index 9187583e8..1d6ca752a 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -120,7 +120,7 @@ function node_last_viewed($nid) {
$history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = '$user->uid' AND nid = %d", $nid));
}
- return ($history[$nid]->timestamp ? $history[$nid]->timestamp : 0);
+ return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0);
}
/**
@@ -353,7 +353,7 @@ function node_load($param = array(), $revision = NULL, $reset = NULL) {
if (is_numeric($param)) {
$cachable = $revision == NULL;
- if ($cachable && $nodes[$param]) {
+ if ($cachable && isset($nodes[$param])) {
return $nodes[$param];
}
$cond = 'n.nid = '. $param;
@@ -1314,7 +1314,7 @@ function node_revision_rollback($nid, $revision) {
global $user;
if (user_access('administer nodes')) {
- if($title = db_fetch_object(db_query('SELECT title, timestamp FROM {node_revisions} WHERE nid = %d AND vid = %d', $nid, $revision))) {
+ if ($title = db_fetch_object(db_query('SELECT title, timestamp FROM {node_revisions} WHERE nid = %d AND vid = %d', $nid, $revision))) {
db_query('UPDATE {node} SET vid = %d, changed = %d WHERE nid = %d', $revision, $title->timestamp, $nid);
drupal_set_message(t('%title has been rolled back to the revision from %revision-date', array('%revision-date' => theme('placeholder', format_date($title->timestamp)), '%title' => theme('placeholder', check_plain($title->title)))));
@@ -1362,8 +1362,8 @@ function node_revision_list($node) {
* Menu callback; presents the content administration overview.
*/
function node_admin() {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
if (empty($op)) {
$op = arg(2);
@@ -1500,20 +1500,20 @@ function node_validate($node) {
// Auto-generate the teaser, but only if it hasn't been set (e.g. by a
// module-provided 'teaser' form item).
if (!isset($node->teaser)) {
- $node->teaser = node_teaser($node->body, $node->format);
+ $node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
}
- if (node_last_changed($node->nid) > $node->changed) {
+ if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
form_set_error('changed', t('This content has been modified by another user, unable to save changes.'));
}
if (user_access('administer nodes')) {
// Set up default values, if required.
- if (!$node->created) {
+ if (!isset($node->created)) {
$node->created = time();
}
- if (!$node->date) {
+ if (!isset($node->date)) {
$node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
}
@@ -1578,9 +1578,9 @@ function node_validate_title($node, $message = NULL) {
* Generate the node editing form.
*/
function node_form($node) {
- $op = $_POST['op'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
- if (!$node->validated) {
+ if (!isset($node) || !isset($node->validated) || !$node->validated) {
$node = node_validate($node);
}
@@ -1664,7 +1664,7 @@ function node_form($node) {
}
function theme_node_form($form) {
- $output .= '<div class="node-form">';
+ $output = '<div class="node-form">';
if (isset($form['node_preview'])) {
$output .= form_render($form['node_preview']);
}
@@ -1690,7 +1690,7 @@ function theme_node_form($form) {
function node_add($type) {
global $user;
- $edit = $_POST['edit'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
// If a node type has been specified, validate its existence.
if (array_key_exists($type, node_get_types()) && node_access('create', $type)) {
@@ -1733,7 +1733,7 @@ function node_add($type) {
* Generate a node preview.
*/
function node_preview($node) {
- if (!$node->validated) {
+ if (!isset($node) || !isset($node->validated) || !$node->validated) {
$node = node_validate($node);
}
diff --git a/modules/node/node.module b/modules/node/node.module
index 9187583e8..1d6ca752a 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -120,7 +120,7 @@ function node_last_viewed($nid) {
$history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = '$user->uid' AND nid = %d", $nid));
}
- return ($history[$nid]->timestamp ? $history[$nid]->timestamp : 0);
+ return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0);
}
/**
@@ -353,7 +353,7 @@ function node_load($param = array(), $revision = NULL, $reset = NULL) {
if (is_numeric($param)) {
$cachable = $revision == NULL;
- if ($cachable && $nodes[$param]) {
+ if ($cachable && isset($nodes[$param])) {
return $nodes[$param];
}
$cond = 'n.nid = '. $param;
@@ -1314,7 +1314,7 @@ function node_revision_rollback($nid, $revision) {
global $user;
if (user_access('administer nodes')) {
- if($title = db_fetch_object(db_query('SELECT title, timestamp FROM {node_revisions} WHERE nid = %d AND vid = %d', $nid, $revision))) {
+ if ($title = db_fetch_object(db_query('SELECT title, timestamp FROM {node_revisions} WHERE nid = %d AND vid = %d', $nid, $revision))) {
db_query('UPDATE {node} SET vid = %d, changed = %d WHERE nid = %d', $revision, $title->timestamp, $nid);
drupal_set_message(t('%title has been rolled back to the revision from %revision-date', array('%revision-date' => theme('placeholder', format_date($title->timestamp)), '%title' => theme('placeholder', check_plain($title->title)))));
@@ -1362,8 +1362,8 @@ function node_revision_list($node) {
* Menu callback; presents the content administration overview.
*/
function node_admin() {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
if (empty($op)) {
$op = arg(2);
@@ -1500,20 +1500,20 @@ function node_validate($node) {
// Auto-generate the teaser, but only if it hasn't been set (e.g. by a
// module-provided 'teaser' form item).
if (!isset($node->teaser)) {
- $node->teaser = node_teaser($node->body, $node->format);
+ $node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : '';
}
- if (node_last_changed($node->nid) > $node->changed) {
+ if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
form_set_error('changed', t('This content has been modified by another user, unable to save changes.'));
}
if (user_access('administer nodes')) {
// Set up default values, if required.
- if (!$node->created) {
+ if (!isset($node->created)) {
$node->created = time();
}
- if (!$node->date) {
+ if (!isset($node->date)) {
$node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
}
@@ -1578,9 +1578,9 @@ function node_validate_title($node, $message = NULL) {
* Generate the node editing form.
*/
function node_form($node) {
- $op = $_POST['op'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
- if (!$node->validated) {
+ if (!isset($node) || !isset($node->validated) || !$node->validated) {
$node = node_validate($node);
}
@@ -1664,7 +1664,7 @@ function node_form($node) {
}
function theme_node_form($form) {
- $output .= '<div class="node-form">';
+ $output = '<div class="node-form">';
if (isset($form['node_preview'])) {
$output .= form_render($form['node_preview']);
}
@@ -1690,7 +1690,7 @@ function theme_node_form($form) {
function node_add($type) {
global $user;
- $edit = $_POST['edit'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
// If a node type has been specified, validate its existence.
if (array_key_exists($type, node_get_types()) && node_access('create', $type)) {
@@ -1733,7 +1733,7 @@ function node_add($type) {
* Generate a node preview.
*/
function node_preview($node) {
- if (!$node->validated) {
+ if (!isset($node) || !isset($node->validated) || !$node->validated) {
$node = node_validate($node);
}
diff --git a/modules/search.module b/modules/search.module
index 54c656e0f..e84f85b22 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -452,7 +452,7 @@ function search_index($sid, $type, $text) {
// None of the tags we look for make sense when nested identically.
// If they are, it's probably broken HTML.
$tagstack = array();
- $score = 1;
+ $score = 1;
}
else {
// Add to open tag stack and increment score
diff --git a/modules/search/search.module b/modules/search/search.module
index 54c656e0f..e84f85b22 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -452,7 +452,7 @@ function search_index($sid, $type, $text) {
// None of the tags we look for make sense when nested identically.
// If they are, it's probably broken HTML.
$tagstack = array();
- $score = 1;
+ $score = 1;
}
else {
// Add to open tag stack and increment score
diff --git a/modules/system.module b/modules/system.module
index b1b3acffa..d41f67fa9 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -525,7 +525,7 @@ function system_theme_data() {
foreach ($themes as $theme) {
foreach (file_scan_directory(dirname($theme->filename), 'style.css$') as $style) {
$style->style = TRUE;
- $style->template = $theme->template;
+ $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;
@@ -560,7 +560,7 @@ function system_theme_data() {
function system_region_list($theme_key) {
static $list = array();
- if(!array_key_exists($theme_key, $list)) {
+ if (!array_key_exists($theme_key, $list)) {
$result = db_query("SELECT * FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key);
$theme = db_fetch_object($result);
@@ -705,7 +705,8 @@ function system_settings_form_execute($form_id, $values) {
}
if ($op == t('Reset to defaults')) {
drupal_set_message(t('The configuration options have been reset to their default values.'));
- } else {
+ }
+ else {
drupal_set_message(t('The configuration options have been saved.'));
}
}
diff --git a/modules/system/system.module b/modules/system/system.module
index b1b3acffa..d41f67fa9 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -525,7 +525,7 @@ function system_theme_data() {
foreach ($themes as $theme) {
foreach (file_scan_directory(dirname($theme->filename), 'style.css$') as $style) {
$style->style = TRUE;
- $style->template = $theme->template;
+ $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;
@@ -560,7 +560,7 @@ function system_theme_data() {
function system_region_list($theme_key) {
static $list = array();
- if(!array_key_exists($theme_key, $list)) {
+ if (!array_key_exists($theme_key, $list)) {
$result = db_query("SELECT * FROM {system} WHERE type = 'theme' AND name = '%s'", $theme_key);
$theme = db_fetch_object($result);
@@ -705,7 +705,8 @@ function system_settings_form_execute($form_id, $values) {
}
if ($op == t('Reset to defaults')) {
drupal_set_message(t('The configuration options have been reset to their default values.'));
- } else {
+ }
+ else {
drupal_set_message(t('The configuration options have been saved.'));
}
}
diff --git a/modules/user.module b/modules/user.module
index ea8975d5d..d01205587 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -601,10 +601,10 @@ function theme_user_picture($account) {
$picture = variable_get('user_picture_default', '');
}
- if ($picture) {
+ if (isset($picture)) {
$alt = t('%user\'s picture', array('%user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
$picture = theme('image', $picture, $alt, $alt, '', false);
- if ($account->uid) {
+ if (!empty($account->uid)) {
$picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
}
@@ -963,7 +963,7 @@ function user_logout() {
function user_pass() {
global $base_url;
- $edit = $_POST['edit'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
if ($edit['name'] && !($account = user_load(array('name' => $edit['name'], 'status' => 1)))) {
form_set_error('name', t('Sorry. The username %name is not recognized.', array('%name' => theme('placeholder', $edit['name']))));
@@ -1044,12 +1044,12 @@ function user_pass_reset($uid, $timestamp, $hashed_pass) {
drupal_access_denied();
}
-function user_pass_reset_url($account){
+function user_pass_reset_url($account) {
$timestamp = time();
return url("user/reset/$account->uid/$timestamp/".user_pass_rehash($account->pass, $timestamp, $account->login), NULL, NULL, TRUE);
}
-function user_pass_rehash($password, $timestamp, $login){
+function user_pass_rehash($password, $timestamp, $login) {
return md5($timestamp . $password . $login);
}
@@ -1310,8 +1310,8 @@ function user_view($uid = 0) {
function user_page() {
global $user;
- $edit = $_POST['edit'];
- $op = $_POST['op'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
if (empty($op)) {
$op = arg(2) ? arg(2) : arg(1);
@@ -1372,13 +1372,11 @@ function user_configure_settings() {
* Menu callback: check an access rule
*/
function user_admin_access_check() {
- if ($_POST['op']) {
- $op = $_POST['op'];
- }
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
- if ($op) {
- if ($edit['user']) {
+ if (!empty($op)) {
+ if (!empty($edit['user']['test'])) {
if (drupal_is_denied('user', $edit['user']['test'])) {
drupal_set_message(t('The username %name is not allowed.', array('%name' => theme('placeholder', $edit['user']['test']))));
}
@@ -1386,7 +1384,7 @@ function user_admin_access_check() {
drupal_set_message(t('The username %name is allowed.', array('%name' => theme('placeholder', $edit['user']['test']))));
}
}
- if ($edit['mail']) {
+ if (!empty($edit['mail']['test'])) {
if (drupal_is_denied('mail', $edit['mail']['test'])) {
drupal_set_message(t('The e-mail address %mail is not allowed.', array('%mail' => theme('placeholder', $edit['mail']['test']))));
}
@@ -1394,7 +1392,7 @@ function user_admin_access_check() {
drupal_set_message(t('The e-mail address %mail is allowed.', array('%mail' => theme('placeholder', $edit['mail']['test']))));
}
}
- if ($edit['host']) {
+ if (!empty($edit['host']['test'])) {
if (drupal_is_denied('host', $edit['host']['test'])) {
drupal_set_message(t('The hostname %host is not allowed.', array('%host' => theme('placeholder', $edit['host']['test']))));
}
@@ -1600,7 +1598,8 @@ function theme_user_admin_perm($form) {
if (is_numeric($key)) {
$row[] = array('data' => form_render($form['permission'][$key]), 'class' => 'module', 'colspan' => count($form['role_names']) + 1);
// Permissions
- } else {
+ }
+ else {
$row[] = array('data' => form_render($form['permission'][$key]), 'class' => 'permission');
foreach (element_children($form['checkboxes']) as $rid) {
if (is_array($form['checkboxes'][$rid])) {
@@ -1652,8 +1651,8 @@ function user_admin_perm_execute() {
* Menu callback: administer roles.
*/
function user_admin_role() {
- $edit = $_POST['edit'];
- $op = $_POST['op'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
$id = arg(4);
if ($op == t('Save role')) {
@@ -1788,8 +1787,8 @@ function user_configure() {
}
function user_admin() {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
if (empty($op)) {
$op = arg(2);
diff --git a/modules/user/user.module b/modules/user/user.module
index ea8975d5d..d01205587 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -601,10 +601,10 @@ function theme_user_picture($account) {
$picture = variable_get('user_picture_default', '');
}
- if ($picture) {
+ if (isset($picture)) {
$alt = t('%user\'s picture', array('%user' => $account->name ? $account->name : variable_get('anonymous', 'Anonymous')));
$picture = theme('image', $picture, $alt, $alt, '', false);
- if ($account->uid) {
+ if (!empty($account->uid)) {
$picture = l($picture, "user/$account->uid", array('title' => t('View user profile.')), NULL, NULL, FALSE, TRUE);
}
@@ -963,7 +963,7 @@ function user_logout() {
function user_pass() {
global $base_url;
- $edit = $_POST['edit'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
if ($edit['name'] && !($account = user_load(array('name' => $edit['name'], 'status' => 1)))) {
form_set_error('name', t('Sorry. The username %name is not recognized.', array('%name' => theme('placeholder', $edit['name']))));
@@ -1044,12 +1044,12 @@ function user_pass_reset($uid, $timestamp, $hashed_pass) {
drupal_access_denied();
}
-function user_pass_reset_url($account){
+function user_pass_reset_url($account) {
$timestamp = time();
return url("user/reset/$account->uid/$timestamp/".user_pass_rehash($account->pass, $timestamp, $account->login), NULL, NULL, TRUE);
}
-function user_pass_rehash($password, $timestamp, $login){
+function user_pass_rehash($password, $timestamp, $login) {
return md5($timestamp . $password . $login);
}
@@ -1310,8 +1310,8 @@ function user_view($uid = 0) {
function user_page() {
global $user;
- $edit = $_POST['edit'];
- $op = $_POST['op'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
if (empty($op)) {
$op = arg(2) ? arg(2) : arg(1);
@@ -1372,13 +1372,11 @@ function user_configure_settings() {
* Menu callback: check an access rule
*/
function user_admin_access_check() {
- if ($_POST['op']) {
- $op = $_POST['op'];
- }
- $edit = $_POST['edit'];
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
- if ($op) {
- if ($edit['user']) {
+ if (!empty($op)) {
+ if (!empty($edit['user']['test'])) {
if (drupal_is_denied('user', $edit['user']['test'])) {
drupal_set_message(t('The username %name is not allowed.', array('%name' => theme('placeholder', $edit['user']['test']))));
}
@@ -1386,7 +1384,7 @@ function user_admin_access_check() {
drupal_set_message(t('The username %name is allowed.', array('%name' => theme('placeholder', $edit['user']['test']))));
}
}
- if ($edit['mail']) {
+ if (!empty($edit['mail']['test'])) {
if (drupal_is_denied('mail', $edit['mail']['test'])) {
drupal_set_message(t('The e-mail address %mail is not allowed.', array('%mail' => theme('placeholder', $edit['mail']['test']))));
}
@@ -1394,7 +1392,7 @@ function user_admin_access_check() {
drupal_set_message(t('The e-mail address %mail is allowed.', array('%mail' => theme('placeholder', $edit['mail']['test']))));
}
}
- if ($edit['host']) {
+ if (!empty($edit['host']['test'])) {
if (drupal_is_denied('host', $edit['host']['test'])) {
drupal_set_message(t('The hostname %host is not allowed.', array('%host' => theme('placeholder', $edit['host']['test']))));
}
@@ -1600,7 +1598,8 @@ function theme_user_admin_perm($form) {
if (is_numeric($key)) {
$row[] = array('data' => form_render($form['permission'][$key]), 'class' => 'module', 'colspan' => count($form['role_names']) + 1);
// Permissions
- } else {
+ }
+ else {
$row[] = array('data' => form_render($form['permission'][$key]), 'class' => 'permission');
foreach (element_children($form['checkboxes']) as $rid) {
if (is_array($form['checkboxes'][$rid])) {
@@ -1652,8 +1651,8 @@ function user_admin_perm_execute() {
* Menu callback: administer roles.
*/
function user_admin_role() {
- $edit = $_POST['edit'];
- $op = $_POST['op'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
$id = arg(4);
if ($op == t('Save role')) {
@@ -1788,8 +1787,8 @@ function user_configure() {
}
function user_admin() {
- $op = $_POST['op'];
- $edit = $_POST['edit'];
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $op = isset($_POST['op']) ? $_POST['op'] : '';
if (empty($op)) {
$op = arg(2);
diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine
index 0f4585c0f..3c8280960 100644
--- a/themes/engines/phptemplate/phptemplate.engine
+++ b/themes/engines/phptemplate/phptemplate.engine
@@ -60,7 +60,7 @@ function _phptemplate_callback($hook, $variables = array(), $file = NULL) {
$variables = array_merge($variables, _phptemplate_variables($hook, $variables));
}
- if ($variables['template_file']) {
+ if (isset($variables['template_file'])) {
$file = $variables['template_file'];
}
@@ -86,13 +86,13 @@ function _phptemplate_callback($hook, $variables = array(), $file = NULL) {
function _phptemplate_default_variables($hook, $variables) {
global $theme;
static $count = array();
- $count[$hook] = is_int($count[$hook]) ? $count[$hook] : 1;
+ $count[$hook] = isset($count[$hook]) && is_int($count[$hook]) ? $count[$hook] : 1;
$variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
$variables['id'] = $count[$hook]++;
global $sidebar_indicator;
if ($hook == 'block') {
- $count['block_counter'][$sidebar_indicator] = is_int($count['block_counter'][$sidebar_indicator]) ? $count['block_counter'][$sidebar_indicator] : 1;
+ $count['block_counter'][$sidebar_indicator] = isset($count['block_counter'][$sidebar_indicator]) && is_int($count['block_counter'][$sidebar_indicator]) ? $count['block_counter'][$sidebar_indicator] : 1;
$variables['block_zebra'] = ($count['block_counter'][$sidebar_indicator] % 2) ? 'odd' : 'even';
$variables['block_id'] = $count['block_counter'][$sidebar_indicator]++;
}
@@ -104,7 +104,7 @@ function _phptemplate_default_variables($hook, $variables) {
// This pre-loading is necessary because phptemplate uses variable names different from
// the region names, e.g., 'sidebar_left' instead of 'left'.
if (!in_array($region, array('left', 'right', 'footer'))) {
- $variables[$region] .= theme('blocks', $region);
+ isset($variables[$region]) ? $variables[$region] .= theme('blocks', $region) : $variables[$region] = theme('blocks', $region);
}
}
}
@@ -118,6 +118,10 @@ function _phptemplate_default_variables($hook, $variables) {
return $variables;
}
+/**
+ * @return
+ * Array of template features
+ */
function phptemplate_features() {
return array(
'logo',
@@ -194,7 +198,7 @@ function phptemplate_page($content) {
'layout' => $layout,
'logo' => theme_get_setting('logo'),
'messages' => theme('status_messages'),
- 'mission' => $mission,
+ 'mission' => isset($mission) ? $mission : '',
'onload_attributes' => theme('onload_attribute'),
'primary_links' => theme_get_setting('primary_links'),
'site_name' => (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : ''),
@@ -263,7 +267,7 @@ function phptemplate_comment($comment, $links = 0) {
'comment' => $comment,
'content' => $comment->comment,
'date' => format_date($comment->timestamp),
- 'links' => $links ? theme('links', $links) : '',
+ 'links' => isset($links) ? theme('links', $links) : '',
'new' => $comment->new ? t('new') : '',
'picture' => theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', $comment) : '',
'submitted' => t('Submitted by %a on %b.',
@@ -309,7 +313,7 @@ function phptemplate_box($title, $content, $region = 'main') {
* A suggested template file to use.
*/
function _phptemplate_default($hook, $variables, $file = NULL) {
- if ($file && file_exists(path_to_theme() . "/$file.tpl.php")) {
+ if (!empty($file) && file_exists(path_to_theme() . "/$file.tpl.php")) {
$file = path_to_theme() . "/$file.tpl.php";
}
else {
@@ -328,8 +332,8 @@ function _phptemplate_default($hook, $variables, $file = NULL) {
}
}
- if ($file) {
- extract($variables, EXTR_SKIP); // Extract the vars to local namespace
+ if (isset($file)) {
+ extract($variables, EXTR_SKIP); // Extract the variables to a local namespace
ob_start(); // Start output buffering
include "./$file"; // Include the file
$contents = ob_get_contents(); // Get the contents of the buffer