diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-08-22 17:03:42 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-08-22 17:03:42 +0000 |
commit | 51cf18e53176244f264c56cab1c4ff0d1767ac59 (patch) | |
tree | 833a665ab48dd0d3a54676d78aa9152b0699f21e | |
parent | 95cb7f32229e229a39e70a76b2b0f6a14cdc5953 (diff) | |
download | brdo-51cf18e53176244f264c56cab1c4ff0d1767ac59.tar.gz brdo-51cf18e53176244f264c56cab1c4ff0d1767ac59.tar.bz2 |
- #9292: Make Drupal (somewhat) PHP5 compatible. xtemplate is still horribly broken.
-rw-r--r-- | includes/common.inc | 5 | ||||
-rw-r--r-- | includes/file.inc | 1 | ||||
-rw-r--r-- | includes/module.inc | 5 | ||||
-rw-r--r-- | modules/block.module | 5 | ||||
-rw-r--r-- | modules/block/block.module | 5 | ||||
-rw-r--r-- | modules/comment.module | 1 | ||||
-rw-r--r-- | modules/comment/comment.module | 1 | ||||
-rw-r--r-- | modules/forum.module | 16 | ||||
-rw-r--r-- | modules/forum/forum.module | 16 | ||||
-rw-r--r-- | modules/node.module | 14 | ||||
-rw-r--r-- | modules/node/node.module | 14 | ||||
-rw-r--r-- | modules/user.module | 19 | ||||
-rw-r--r-- | modules/user/user.module | 19 | ||||
-rw-r--r-- | themes/chameleon/chameleon.theme | 1 | ||||
-rw-r--r-- | themes/engines/xtemplate/xtemplate.engine | 1 |
15 files changed, 92 insertions, 31 deletions
diff --git a/includes/common.inc b/includes/common.inc index e8080e7f0..72324c5f0 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -399,10 +399,10 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = * Log errors in the database rather than displaying them to the user. */ function error_handler($errno, $message, $filename, $line, $variables) { - $types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice'); + $types = array(1 => 'error', 2 => 'warning', 4 => 'parse error', 8 => 'notice', 16 => 'core error', 32 => 'core warning', 64 => 'compile error', 128 => 'compile warning', 256 => 'user error', 512 => 'user warning', 1024 => 'user notice', 2048 => 'strict warning'); $entry = $types[$errno] .': '. $message .' in '. $filename .' on line '. $line .'.'; - if ($errno & E_ALL ^ E_NOTICE) { + if ($errno & (E_ALL ^ E_NOTICE)) { watchdog('error', t('%error: %message in %file on line %line.', array('%error' => $types[$errno], '%message' => $message, '%file' => $filename, '%line' => $line))); if (error_reporting()) { print '<pre>'. $entry .'</pre>'; @@ -446,6 +446,7 @@ function fix_gpc_magic() { */ function array2object($array) { if (is_array($array)) { + $object = new stdClass(); foreach ($array as $key => $value) { $object->$key = $value; } diff --git a/includes/file.inc b/includes/file.inc index a8f447b76..1d4399f5d 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -442,6 +442,7 @@ function file_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $ca } elseif (ereg($mask, $file)) { $name = basename($file); + $files["$dir/$file"] = new stdClass(); $files["$dir/$file"]->filename = "$dir/$file"; $files["$dir/$file"]->name = substr($name, 0, strrpos($name, '.')); if ($callback) { diff --git a/includes/module.inc b/includes/module.inc index 18c7dfb4c..62c2cbae9 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -238,9 +238,12 @@ function module_invoke_all($hook, $a1 = NULL, $a2 = NULL, $a3 = NULL, $a4 = NULL $return = array(); foreach (module_list() as $module) { $result = module_invoke($module, $hook, $a1, $a2, $a3, $a4); - if (isset($result)) { + if (is_array($result)) { $return = array_merge($return, $result); } + else if (isset($result)) { + $return[] = $result; + } } return $return; diff --git a/modules/block.module b/modules/block.module index 5ecf0f9ae..df0a67618 100644 --- a/modules/block.module +++ b/modules/block.module @@ -365,7 +365,10 @@ function block_list($region) { ** based on server load. */ if (!($block['throttle'] && (module_invoke('throttle', 'status') > 4))) { - $block = array_merge($block, module_invoke($block['module'], 'block', 'view', $block['delta'])); + $array = module_invoke($block['module'], 'block', 'view', $block['delta']); + if (is_array($array)) { + $block = array_merge($block, $array); + } } if (isset($block['content']) && $block['content']) { $blocks[$region]["$block[module]_$block[delta]"] = (object) $block; diff --git a/modules/block/block.module b/modules/block/block.module index 5ecf0f9ae..df0a67618 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -365,7 +365,10 @@ function block_list($region) { ** based on server load. */ if (!($block['throttle'] && (module_invoke('throttle', 'status') > 4))) { - $block = array_merge($block, module_invoke($block['module'], 'block', 'view', $block['delta'])); + $array = module_invoke($block['module'], 'block', 'view', $block['delta']); + if (is_array($array)) { + $block = array_merge($block, $array); + } } if (isset($block['content']) && $block['content']) { $blocks[$region]["$block[module]_$block[delta]"] = (object) $block; diff --git a/modules/comment.module b/modules/comment.module index 0f9980b67..923381af0 100644 --- a/modules/comment.module +++ b/modules/comment.module @@ -502,6 +502,7 @@ function comment_preview($edit) { $output = ''; + $comment = new StdClass(); foreach ($edit as $key => $value) { $comment->$key = $value; } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 0f9980b67..923381af0 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -502,6 +502,7 @@ function comment_preview($edit) { $output = ''; + $comment = new StdClass(); foreach ($edit as $key => $value) { $comment->$key = $value; } diff --git a/modules/forum.module b/modules/forum.module index e90df6d9c..9be309d16 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -157,6 +157,7 @@ function forum_link($type, $node = 0, $main = 0) { while ($topic = db_fetch_object($result)) { if ($stop == 1) { + $next = new StdClass(); $next->nid = $topic->nid; $next->title = $topic->title; break; @@ -311,7 +312,12 @@ function _forum_last_comment($nid) { function _forum_last_reply($nid) { $value = db_fetch_object(db_query_range('SELECT c.timestamp, c.name AS anonymous_name, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = 0 ORDER BY c.timestamp DESC', $nid, 0, 1)); - $value->name = $value->uid ? $value->name : $value->anonymous_name; + if ($value) { + $value->name = $value->uid ? $value->name : $value->anonymous_name; + } + else { + $value = new StdClass(); + } return $value; } @@ -373,9 +379,13 @@ function _forum_topics_read($term, $uid) { function _forum_last_post($term) { $topic = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), n.created AS timestamp, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {users} u ON n.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY timestamp DESC", $term, 0, 1)); - $reply = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), c.timestamp, c.name AS anonymous_name, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {comments} c ON n.nid = c.nid INNER JOIN {users} u ON c.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." AND c.status = 0 ORDER BY c.timestamp DESC", $term, 0, 1)); - $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + if ($reply) { + $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + } + else { + $reply = new StdClass(); + } $value = ($topic->timestamp > $reply->timestamp) ? $topic : $reply; diff --git a/modules/forum/forum.module b/modules/forum/forum.module index e90df6d9c..9be309d16 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -157,6 +157,7 @@ function forum_link($type, $node = 0, $main = 0) { while ($topic = db_fetch_object($result)) { if ($stop == 1) { + $next = new StdClass(); $next->nid = $topic->nid; $next->title = $topic->title; break; @@ -311,7 +312,12 @@ function _forum_last_comment($nid) { function _forum_last_reply($nid) { $value = db_fetch_object(db_query_range('SELECT c.timestamp, c.name AS anonymous_name, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d AND c.status = 0 ORDER BY c.timestamp DESC', $nid, 0, 1)); - $value->name = $value->uid ? $value->name : $value->anonymous_name; + if ($value) { + $value->name = $value->uid ? $value->name : $value->anonymous_name; + } + else { + $value = new StdClass(); + } return $value; } @@ -373,9 +379,13 @@ function _forum_topics_read($term, $uid) { function _forum_last_post($term) { $topic = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), n.created AS timestamp, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {users} u ON n.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." ORDER BY timestamp DESC", $term, 0, 1)); - $reply = db_fetch_object(db_query_range("SELECT DISTINCT(n.nid), c.timestamp, c.name AS anonymous_name, u.name AS name, u.uid AS uid FROM {forum} f INNER JOIN {node} n ON n.nid = f.nid ". node_access_join_sql() ." INNER JOIN {comments} c ON n.nid = c.nid INNER JOIN {users} u ON c.uid = u.uid WHERE f.tid = %d AND n.nid = f.nid AND n.type = 'forum' AND n.status = 1 AND ". node_access_where_sql() ." AND c.status = 0 ORDER BY c.timestamp DESC", $term, 0, 1)); - $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + if ($reply) { + $reply->name = $reply->uid ? $reply->name : $reply->anonymous_name; + } + else { + $reply = new StdClass(); + } $value = ($topic->timestamp > $reply->timestamp) ? $topic : $reply; diff --git a/modules/node.module b/modules/node.module index 62a9e5426..6deaa6763 100644 --- a/modules/node.module +++ b/modules/node.module @@ -347,9 +347,12 @@ function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { $function = $name .'_nodeapi'; if (function_exists($function)) { $result = $function($node, $op, $a3, $a4); - if (isset($result)) { + if (is_array($result)) { $return = array_merge($return, $result); } + else { + $return[] = $result; + } } } return $return; @@ -397,7 +400,7 @@ function node_load($conditions, $revision = -1) { } // Return the desired revision. - if ($revision != -1 && isset($node->revisions[$revision])) { + if ($revision != -1 && is_array($node->revisions[$revision])) { $node = $node->revisions[$revision]['node']; } @@ -814,6 +817,7 @@ function node_default_settings() { $header = array_merge(array(t('type')), array_keys(node_invoke_nodeapi($node, 'settings'))); foreach (node_list() as $type) { + $node = new StdClass(); $node->type = $type; $cols = array(); foreach (node_invoke_nodeapi($node, 'settings') as $setting) { @@ -1221,7 +1225,11 @@ function node_form($edit) { } } - return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], array_merge($param['options'], array('id' => 'node-form'))); + $attributes = array('id' => 'node-form'); + if (is_array($param['options'])) { + $attributes = array_merge($param['options'], $attributes); + } + return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $attributes); } /** diff --git a/modules/node/node.module b/modules/node/node.module index 62a9e5426..6deaa6763 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -347,9 +347,12 @@ function node_invoke_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { $function = $name .'_nodeapi'; if (function_exists($function)) { $result = $function($node, $op, $a3, $a4); - if (isset($result)) { + if (is_array($result)) { $return = array_merge($return, $result); } + else { + $return[] = $result; + } } } return $return; @@ -397,7 +400,7 @@ function node_load($conditions, $revision = -1) { } // Return the desired revision. - if ($revision != -1 && isset($node->revisions[$revision])) { + if ($revision != -1 && is_array($node->revisions[$revision])) { $node = $node->revisions[$revision]['node']; } @@ -814,6 +817,7 @@ function node_default_settings() { $header = array_merge(array(t('type')), array_keys(node_invoke_nodeapi($node, 'settings'))); foreach (node_list() as $type) { + $node = new StdClass(); $node->type = $type; $cols = array(); foreach (node_invoke_nodeapi($node, 'settings') as $setting) { @@ -1221,7 +1225,11 @@ function node_form($edit) { } } - return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], array_merge($param['options'], array('id' => 'node-form'))); + $attributes = array('id' => 'node-form'); + if (is_array($param['options'])) { + $attributes = array_merge($param['options'], $attributes); + } + return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $attributes); } /** diff --git a/modules/user.module b/modules/user.module index 915d3414f..bb77c128f 100644 --- a/modules/user.module +++ b/modules/user.module @@ -54,14 +54,19 @@ function user_load($array = array()) { } $result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", 0, 1); - $user = db_fetch_object($result); - $user = drupal_unpack($user); - user_module_invoke('load', $array, $user); + if (db_num_rows($result)) { + $user = db_fetch_object($result); + $user = drupal_unpack($user); + user_module_invoke('load', $array, $user); - $user->roles = array(); - $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); - while ($role = db_fetch_object($result)) { - $user->roles[$role->rid] = $role->name; + $user->roles = array(); + $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); + while ($role = db_fetch_object($result)) { + $user->roles[$role->rid] = $role->name; + } + } + else { + $user = new StdClass(); } return $user; diff --git a/modules/user/user.module b/modules/user/user.module index 915d3414f..bb77c128f 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -54,14 +54,19 @@ function user_load($array = array()) { } $result = db_query_range("SELECT u.* FROM {users} u WHERE $query u.status < 3", 0, 1); - $user = db_fetch_object($result); - $user = drupal_unpack($user); - user_module_invoke('load', $array, $user); + if (db_num_rows($result)) { + $user = db_fetch_object($result); + $user = drupal_unpack($user); + user_module_invoke('load', $array, $user); - $user->roles = array(); - $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); - while ($role = db_fetch_object($result)) { - $user->roles[$role->rid] = $role->name; + $user->roles = array(); + $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); + while ($role = db_fetch_object($result)) { + $user->roles[$role->rid] = $role->name; + } + } + else { + $user = new StdClass(); } return $user; diff --git a/themes/chameleon/chameleon.theme b/themes/chameleon/chameleon.theme index 44df7589b..154cb2e4b 100644 --- a/themes/chameleon/chameleon.theme +++ b/themes/chameleon/chameleon.theme @@ -129,6 +129,7 @@ function chameleon_node($node, $main = 0, $page = 0) { $submitted = theme_get_setting("toggle_node_info_$node->type") ? array(t("By %author at %date", array('%author' => format_name($node), '%date' => format_date($node->created, 'small')))) : array(); + $terms = array(); if (module_exist('taxonomy')) { $terms = taxonomy_link("taxonomy terms", $node); } diff --git a/themes/engines/xtemplate/xtemplate.engine b/themes/engines/xtemplate/xtemplate.engine index 6bcffc65a..2b91f70d7 100644 --- a/themes/engines/xtemplate/xtemplate.engine +++ b/themes/engines/xtemplate/xtemplate.engine @@ -12,6 +12,7 @@ function xtemplate_init($template) { if (!class_exists('XTemplate')) { include_once('themes/engines/xtemplate/xtemplate.inc'); } + $GLOBALS["xtemplate"] = new StdClass(); $GLOBALS['xtemplate']->template = new XTemplate(basename($template->filename), dirname($template->filename)); $GLOBALS['xtemplate']->template->SetNullBlock(' '); // '' doesnt work! } |