summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-12-31 10:48:56 +0000
committerDries Buytaert <dries@buytaert.net>2005-12-31 10:48:56 +0000
commitea2d79109595f0c936259ffacfccd904f8dcd599 (patch)
treeba709e7605b91af6bbb0c613850be03f83e88935
parent9ff2c1b3a8c5fcbf656cc744f210fc37f16a5075 (diff)
downloadbrdo-ea2d79109595f0c936259ffacfccd904f8dcd599.tar.gz
brdo-ea2d79109595f0c936259ffacfccd904f8dcd599.tar.bz2
- Patch 41169 by Chris: got rid of expensvie object 2 array casts.
-rw-r--r--includes/common.inc44
-rw-r--r--misc/drupal.js2
-rw-r--r--misc/textarea.js6
-rw-r--r--modules/blogapi.module4
-rw-r--r--modules/blogapi/blogapi.module4
-rw-r--r--modules/comment.module4
-rw-r--r--modules/comment/comment.module4
-rw-r--r--modules/forum.module4
-rw-r--r--modules/forum/forum.module4
-rw-r--r--modules/node.module12
-rw-r--r--modules/node/node.module12
-rw-r--r--modules/taxonomy.module4
-rw-r--r--modules/taxonomy/taxonomy.module4
-rw-r--r--modules/upload.module2
-rw-r--r--modules/upload/upload.module2
-rw-r--r--modules/user.module4
-rw-r--r--modules/user/user.module4
-rw-r--r--themes/engines/phptemplate/phptemplate.engine2
18 files changed, 39 insertions, 83 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 6fc543633..210403561 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -490,50 +490,6 @@ function fix_gpc_magic() {
}
/**
- * @name Conversion
- * @{
- * Converts data structures to different types.
- */
-
-/**
- * Convert an associative array to an anonymous object.
- */
-function array2object($array) {
- if (is_array($array)) {
- $object = new StdClass();
- foreach ($array as $key => $value) {
- $object->$key = $value;
- }
- }
- else {
- $object = $array;
- }
-
- return $object;
-}
-
-/**
- * Convert an object to an associative array.
- */
-function object2array($object) {
- if (is_object($object)) {
- foreach ($object as $key => $value) {
- $array[$key] = $value;
- }
- }
- else {
- $array = $object;
- }
-
- return $array;
-}
-
-
-/**
- * @} End of "Conversion".
- */
-
-/**
* @name Messages
* @{
* Frequently used messages.
diff --git a/misc/drupal.js b/misc/drupal.js
index c19dc565a..7f3a44cea 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -294,7 +294,7 @@ function stopEvent(event) {
else {
event.returnValue = false;
event.cancelBubble = true;
- }
+ }
}
/**
diff --git a/misc/textarea.js b/misc/textarea.js
index dc9bce69c..e33c35bcc 100644
--- a/misc/textarea.js
+++ b/misc/textarea.js
@@ -6,7 +6,7 @@ if (isJsEnabled()) {
for (var i = 0; textarea = textareas[i]; ++i) {
if (hasClass(textarea, 'resizable')) {
if (typeof dimensions(textarea).width != 'undefined' && dimensions(textarea).width != 0) {
- new textArea(textarea);
+ new textArea(textarea);
}
}
}
@@ -18,7 +18,7 @@ function textArea(element) {
this.element = element;
this.parent = this.element.parentNode;
this.dimensions = dimensions(element);
-
+
// Prepare wrapper
this.wrapper = document.createElement('div');
this.wrapper.className = 'resizable-textarea';
@@ -56,7 +56,7 @@ function textArea(element) {
this.grippie.style.paddingLeft = '2px';
}
// Mozilla
- this.element.style.MozBoxSizing = 'border-box';
+ this.element.style.MozBoxSizing = 'border-box';
this.heightOffset = absolutePosition(this.grippie).y - absolutePosition(this.element).y - this.dimensions.height;
}
diff --git a/modules/blogapi.module b/modules/blogapi.module
index 8b284b241..2e5fef9bc 100644
--- a/modules/blogapi.module
+++ b/modules/blogapi.module
@@ -629,7 +629,7 @@ __RSD__;
function _blogapi_mt_extra(&$node, $struct) {
if (is_array($node)) {
$was_array = true;
- $node = array2object($node);
+ $node = (object)$node;
}
// mt_allow_comments
@@ -681,7 +681,7 @@ function _blogapi_mt_extra(&$node, $struct) {
}
if ($was_array) {
- $node = object2array($node);
+ $node = (array)$node;
}
}
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index 8b284b241..2e5fef9bc 100644
--- a/modules/blogapi/blogapi.module
+++ b/modules/blogapi/blogapi.module
@@ -629,7 +629,7 @@ __RSD__;
function _blogapi_mt_extra(&$node, $struct) {
if (is_array($node)) {
$was_array = true;
- $node = array2object($node);
+ $node = (object)$node;
}
// mt_allow_comments
@@ -681,7 +681,7 @@ function _blogapi_mt_extra(&$node, $struct) {
}
if ($was_array) {
- $node = object2array($node);
+ $node = (array)$node;
}
}
diff --git a/modules/comment.module b/modules/comment.module
index 6bd67757c..3820d27d8 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -444,7 +444,7 @@ function comment_edit($cid) {
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
if (comment_access('edit', $comment)) {
- return comment_form(object2array($comment));
+ return comment_form((array)$comment);
}
else {
drupal_access_denied();
@@ -1349,7 +1349,7 @@ function comment_form_add_preview($form, $edit) {
$output = '';
- $comment = array2object(comment_validate($edit));
+ $comment = (object)comment_validate($edit);
// Attach the user and time information.
if ($edit['author']) {
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 6bd67757c..3820d27d8 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -444,7 +444,7 @@ function comment_edit($cid) {
$comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name;
if (comment_access('edit', $comment)) {
- return comment_form(object2array($comment));
+ return comment_form((array)$comment);
}
else {
drupal_access_denied();
@@ -1349,7 +1349,7 @@ function comment_form_add_preview($form, $edit) {
$output = '';
- $comment = array2object(comment_validate($edit));
+ $comment = (object)comment_validate($edit);
// Attach the user and time information.
if ($edit['author']) {
diff --git a/modules/forum.module b/modules/forum.module
index a298e4234..8e22f6b3b 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -105,10 +105,10 @@ function forum_admin() {
break;
case 'edit':
if (arg(3) == 'forum') {
- $output = forum_form_forum(object2array(taxonomy_get_term(arg(4))));
+ $output = forum_form_forum((array)taxonomy_get_term(arg(4)));
}
else if (arg(3) == 'container') {
- $output = forum_form_container(object2array(taxonomy_get_term(arg(4))));
+ $output = forum_form_container((array)taxonomy_get_term(arg(4)));
}
break;
case t('Delete'):
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index a298e4234..8e22f6b3b 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -105,10 +105,10 @@ function forum_admin() {
break;
case 'edit':
if (arg(3) == 'forum') {
- $output = forum_form_forum(object2array(taxonomy_get_term(arg(4))));
+ $output = forum_form_forum((array)taxonomy_get_term(arg(4)));
}
else if (arg(3) == 'container') {
- $output = forum_form_container(object2array(taxonomy_get_term(arg(4))));
+ $output = forum_form_container((array)taxonomy_get_term(arg(4)));
}
break;
case t('Delete'):
diff --git a/modules/node.module b/modules/node.module
index 46789e403..6b033e372 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -513,7 +513,7 @@ function node_save(&$node) {
* An HTML representation of the themed node.
*/
function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
- $node = array2object($node);
+ $node = (object)$node;
// Remove the delimiter (if any) that separates the teaser from the body.
// TODO: this strips legitimate uses of '<!--break-->' also.
@@ -1493,7 +1493,7 @@ function node_submit($node) {
global $user;
// Convert the node to an object, if necessary.
- $node = array2object($node);
+ $node = (object)$node;
// Auto-generate the teaser, but only if it hasn't been set (e.g. by a
// module-provided 'teaser' form item).
@@ -1539,7 +1539,7 @@ function node_submit($node) {
*/
function node_validate($node) {
// Convert the node to an object, if necessary.
- $node = array2object($node);
+ $node = (object)$node;
// Make sure the body has the minimum number of words.
// todo use a better word counting algorithm that will work in other languages
@@ -1609,7 +1609,7 @@ function node_object_prepare(&$node) {
function node_form($node) {
$op = isset($_POST['op']) ? $_POST['op'] : '';
- $node = array2object($node);
+ $node = (object)$node;
node_object_prepare($node);
// Set the id of the top-level form tag
@@ -1693,7 +1693,7 @@ function node_form($node) {
}
function node_form_add_preview($form, $edit) {
- $edit = array2object($edit);
+ $edit = (object)$edit;
node_validate($edit);
$form['node_preview'] = array('#value' => node_preview($edit), '#weight' => -100);
return $form;
@@ -2167,7 +2167,7 @@ function node_form_alter($form_id, &$form) {
*/
function node_access($op, $node = NULL, $uid = NULL) {
// Convert the node to an object if necessary:
- $node = array2object($node);
+ $node = (object)$node;
// If the node is in a restricted format, disallow editing.
if ($op == 'update' && !filter_access($node->format)) {
diff --git a/modules/node/node.module b/modules/node/node.module
index 46789e403..6b033e372 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -513,7 +513,7 @@ function node_save(&$node) {
* An HTML representation of the themed node.
*/
function node_view($node, $teaser = FALSE, $page = FALSE, $links = TRUE) {
- $node = array2object($node);
+ $node = (object)$node;
// Remove the delimiter (if any) that separates the teaser from the body.
// TODO: this strips legitimate uses of '<!--break-->' also.
@@ -1493,7 +1493,7 @@ function node_submit($node) {
global $user;
// Convert the node to an object, if necessary.
- $node = array2object($node);
+ $node = (object)$node;
// Auto-generate the teaser, but only if it hasn't been set (e.g. by a
// module-provided 'teaser' form item).
@@ -1539,7 +1539,7 @@ function node_submit($node) {
*/
function node_validate($node) {
// Convert the node to an object, if necessary.
- $node = array2object($node);
+ $node = (object)$node;
// Make sure the body has the minimum number of words.
// todo use a better word counting algorithm that will work in other languages
@@ -1609,7 +1609,7 @@ function node_object_prepare(&$node) {
function node_form($node) {
$op = isset($_POST['op']) ? $_POST['op'] : '';
- $node = array2object($node);
+ $node = (object)$node;
node_object_prepare($node);
// Set the id of the top-level form tag
@@ -1693,7 +1693,7 @@ function node_form($node) {
}
function node_form_add_preview($form, $edit) {
- $edit = array2object($edit);
+ $edit = (object)$edit;
node_validate($edit);
$form['node_preview'] = array('#value' => node_preview($edit), '#weight' => -100);
return $form;
@@ -2167,7 +2167,7 @@ function node_form_alter($form_id, &$form) {
*/
function node_access($op, $node = NULL, $uid = NULL) {
// Convert the node to an object if necessary:
- $node = array2object($node);
+ $node = (object)$node;
// If the node is in a restricted format, disallow editing.
if ($op == 'update' && !filter_access($node->format)) {
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index 5abbbe89d..e0a6cc642 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -1126,10 +1126,10 @@ function taxonomy_admin() {
break;
case 'edit':
if (arg(3) == 'vocabulary') {
- $output = taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4))));
+ $output = taxonomy_form_vocabulary((array)taxonomy_get_vocabulary(arg(4)));
}
else if (arg(3) == 'term') {
- $output = taxonomy_form_term(object2array(taxonomy_get_term(arg(4))));
+ $output = taxonomy_form_term((array)taxonomy_get_term(arg(4)));
}
break;
case t('Delete'):
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 5abbbe89d..e0a6cc642 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1126,10 +1126,10 @@ function taxonomy_admin() {
break;
case 'edit':
if (arg(3) == 'vocabulary') {
- $output = taxonomy_form_vocabulary(object2array(taxonomy_get_vocabulary(arg(4))));
+ $output = taxonomy_form_vocabulary((array)taxonomy_get_vocabulary(arg(4)));
}
else if (arg(3) == 'term') {
- $output = taxonomy_form_term(object2array(taxonomy_get_term(arg(4))));
+ $output = taxonomy_form_term((array)taxonomy_get_term(arg(4)));
}
break;
case t('Delete'):
diff --git a/modules/upload.module b/modules/upload.module
index d5c7a49bd..957454f99 100644
--- a/modules/upload.module
+++ b/modules/upload.module
@@ -536,7 +536,7 @@ function _upload_image($file) {
*/
function upload_js() {
// We only do the upload.module part of the node validation process.
- $node = array2object($_POST['edit']);
+ $node = (object)$_POST['edit'];
upload_nodeapi($node, 'validate', NULL);
$form = _upload_form($node);
$form = _form_builder('upload_js', $form);
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index d5c7a49bd..957454f99 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -536,7 +536,7 @@ function _upload_image($file) {
*/
function upload_js() {
// We only do the upload.module part of the node validation process.
- $node = array2object($_POST['edit']);
+ $node = (object)$_POST['edit'];
upload_nodeapi($node, 'validate', NULL);
$form = _upload_form($node);
$form = _form_builder('upload_js', $form);
diff --git a/modules/user.module b/modules/user.module
index 7e0e24688..6d90de404 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -1177,7 +1177,7 @@ function user_edit_form($uid, $edit) {
// Picture/avatar:
if (variable_get('user_pictures', 0)) {
$form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
- if ($edit['picture'] && ($picture = theme('user_picture', array2object($edit)))) {
+ if ($edit['picture'] && ($picture = theme('user_picture', (object)$edit))) {
$form['picture']['current_picture'] = array('#type' => 'markup', '#value' => $picture);
$form['picture']['picture_delete'] = array('#type' => 'checkbox', '#title' => t('Delete picture'), '#description' => t('Check this box to delete your current picture.'));
}
@@ -1257,7 +1257,7 @@ function user_edit($category = 'account') {
global $user;
$account = user_load(array('uid' => arg(1)));
- $edit = $_POST['op'] ? $_POST['edit'] : object2array($account);
+ $edit = $_POST['op'] ? $_POST['edit'] : (array)$account;
if (arg(2) == 'delete') {
if ($edit['confirm']) {
diff --git a/modules/user/user.module b/modules/user/user.module
index 7e0e24688..6d90de404 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -1177,7 +1177,7 @@ function user_edit_form($uid, $edit) {
// Picture/avatar:
if (variable_get('user_pictures', 0)) {
$form['picture'] = array('#type' => 'fieldset', '#title' => t('Picture'), '#weight' => 1);
- if ($edit['picture'] && ($picture = theme('user_picture', array2object($edit)))) {
+ if ($edit['picture'] && ($picture = theme('user_picture', (object)$edit))) {
$form['picture']['current_picture'] = array('#type' => 'markup', '#value' => $picture);
$form['picture']['picture_delete'] = array('#type' => 'checkbox', '#title' => t('Delete picture'), '#description' => t('Check this box to delete your current picture.'));
}
@@ -1257,7 +1257,7 @@ function user_edit($category = 'account') {
global $user;
$account = user_load(array('uid' => arg(1)));
- $edit = $_POST['op'] ? $_POST['edit'] : object2array($account);
+ $edit = $_POST['op'] ? $_POST['edit'] : (array)$account;
if (arg(2) == 'delete') {
if ($edit['confirm']) {
diff --git a/themes/engines/phptemplate/phptemplate.engine b/themes/engines/phptemplate/phptemplate.engine
index 94a40a5ba..ac98567f7 100644
--- a/themes/engines/phptemplate/phptemplate.engine
+++ b/themes/engines/phptemplate/phptemplate.engine
@@ -244,7 +244,7 @@ function phptemplate_node($node, $teaser = 0, $page = 0) {
);
// Flatten the node object's member fields.
- $variables = array_merge(object2array($node), $variables);
+ $variables = array_merge((array)$node, $variables);
// Display info only on certain node types.
if (theme_get_setting('toggle_node_info_' . $node->type)) {