From 04fb2f6fc8a49498a8de0600e5e9b4172b27b5f0 Mon Sep 17 00:00:00 2001 From: ewinslow Date: Sat, 20 Nov 2010 10:09:20 +0000 Subject: Fixes #2490: attributes initialize to NULL instead of empty string or 0. Updated tests to reflect this git-svn-id: http://code.elgg.org/elgg/trunk@7376 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggData.php | 2 +- engine/classes/ElggEntity.php | 12 ++++++------ engine/classes/ElggExtender.php | 2 +- engine/classes/ElggGroup.php | 4 ++-- engine/classes/ElggObject.php | 4 ++-- engine/classes/ElggSite.php | 6 +++--- engine/classes/ElggUser.php | 14 +++++++------- engine/tests/objects/entities.php | 14 +++++++------- engine/tests/objects/objects.php | 16 ++++++++-------- engine/tests/objects/sites.php | 18 +++++++++--------- engine/tests/objects/users.php | 26 +++++++++++++------------- 11 files changed, 59 insertions(+), 59 deletions(-) diff --git a/engine/classes/ElggData.php b/engine/classes/ElggData.php index 96de1bc8f..a6cf7d21f 100644 --- a/engine/classes/ElggData.php +++ b/engine/classes/ElggData.php @@ -36,7 +36,7 @@ abstract class ElggData implements $this->attributes = array(); } - $this->attributes['time_created'] = ''; + $this->attributes['time_created'] = NULL; } /** diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index 0cf3da8fa..667302c30 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -84,17 +84,17 @@ abstract class ElggEntity extends ElggData implements protected function initializeAttributes() { parent::initializeAttributes(); - $this->attributes['guid'] = ""; - $this->attributes['type'] = ""; - $this->attributes['subtype'] = ""; + $this->attributes['guid'] = NULL; + $this->attributes['type'] = NULL; + $this->attributes['subtype'] = NULL; $this->attributes['owner_guid'] = get_loggedin_userid(); $this->attributes['container_guid'] = get_loggedin_userid(); - $this->attributes['site_guid'] = 0; + $this->attributes['site_guid'] = NULL; $this->attributes['access_id'] = ACCESS_PRIVATE; - $this->attributes['time_updated'] = ""; - $this->attributes['last_action'] = ''; + $this->attributes['time_updated'] = NULL; + $this->attributes['last_action'] = NULL; $this->attributes['enabled'] = "yes"; // There now follows a bit of a hack diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php index 78ccea395..95a4d3de3 100644 --- a/engine/classes/ElggExtender.php +++ b/engine/classes/ElggExtender.php @@ -22,7 +22,7 @@ abstract class ElggExtender extends ElggData protected function initializeAttributes() { parent::initializeAttributes(); - $this->attributes['type'] = ''; + $this->attributes['type'] = NULL; } /** diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index 71b2a37d4..448c1f7a6 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -33,8 +33,8 @@ class ElggGroup extends ElggEntity parent::initializeAttributes(); $this->attributes['type'] = "group"; - $this->attributes['name'] = ""; - $this->attributes['description'] = ""; + $this->attributes['name'] = NULL; + $this->attributes['description'] = NULL; $this->attributes['tables_split'] = 2; } diff --git a/engine/classes/ElggObject.php b/engine/classes/ElggObject.php index a808f4b9f..74c7be248 100644 --- a/engine/classes/ElggObject.php +++ b/engine/classes/ElggObject.php @@ -40,8 +40,8 @@ class ElggObject extends ElggEntity { parent::initializeAttributes(); $this->attributes['type'] = "object"; - $this->attributes['title'] = ""; - $this->attributes['description'] = ""; + $this->attributes['title'] = NULL; + $this->attributes['description'] = NULL; $this->attributes['tables_split'] = 2; } diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 70ad395fe..da239f1be 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -51,9 +51,9 @@ class ElggSite extends ElggEntity { parent::initializeAttributes(); $this->attributes['type'] = "site"; - $this->attributes['name'] = ""; - $this->attributes['description'] = ""; - $this->attributes['url'] = ""; + $this->attributes['name'] = NULL; + $this->attributes['description'] = NULL; + $this->attributes['url'] = NULL; $this->attributes['tables_split'] = 2; } diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index cb2d565fc..8f30be37e 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -37,13 +37,13 @@ class ElggUser extends ElggEntity parent::initializeAttributes(); $this->attributes['type'] = "user"; - $this->attributes['name'] = ""; - $this->attributes['username'] = ""; - $this->attributes['password'] = ""; - $this->attributes['salt'] = ""; - $this->attributes['email'] = ""; - $this->attributes['language'] = ""; - $this->attributes['code'] = ""; + $this->attributes['name'] = NULL; + $this->attributes['username'] = NULL; + $this->attributes['password'] = NULL; + $this->attributes['salt'] = NULL; + $this->attributes['email'] = NULL; + $this->attributes['language'] = NULL; + $this->attributes['code'] = NULL; $this->attributes['banned'] = "no"; $this->attributes['admin'] = 'no'; $this->attributes['tables_split'] = 2; diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 24c6859b1..97cf44392 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -26,16 +26,16 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { */ public function testElggEntityAttributes() { $test_attributes = array(); - $test_attributes['guid'] = ''; - $test_attributes['type'] = ''; - $test_attributes['subtype'] = ''; + $test_attributes['guid'] = NULL; + $test_attributes['type'] = NULL; + $test_attributes['subtype'] = NULL; $test_attributes['owner_guid'] = get_loggedin_userid(); $test_attributes['container_guid'] = get_loggedin_userid(); - $test_attributes['site_guid'] = 0; + $test_attributes['site_guid'] = NULL; $test_attributes['access_id'] = ACCESS_PRIVATE; - $test_attributes['time_created'] = ''; - $test_attributes['time_updated'] = ''; - $test_attributes['last_action'] = ''; + $test_attributes['time_created'] = NULL; + $test_attributes['time_updated'] = NULL; + $test_attributes['last_action'] = NULL; $test_attributes['enabled'] = 'yes'; $test_attributes['tables_split'] = 1; $test_attributes['tables_loaded'] = 0; diff --git a/engine/tests/objects/objects.php b/engine/tests/objects/objects.php index 479c83766..95f507695 100644 --- a/engine/tests/objects/objects.php +++ b/engine/tests/objects/objects.php @@ -38,21 +38,21 @@ class ElggCoreObjectTest extends ElggCoreUnitTest { public function testElggObjectConstructor() { $attributes = array(); - $attributes['guid'] = ''; + $attributes['guid'] = NULL; $attributes['type'] = 'object'; - $attributes['subtype'] = ''; + $attributes['subtype'] = NULL; $attributes['owner_guid'] = get_loggedin_userid(); $attributes['container_guid'] = get_loggedin_userid(); - $attributes['site_guid'] = 0; + $attributes['site_guid'] = NULL; $attributes['access_id'] = ACCESS_PRIVATE; - $attributes['time_created'] = ''; - $attributes['time_updated'] = ''; - $attributes['last_action'] = ''; + $attributes['time_created'] = NULL; + $attributes['time_updated'] = NULL; + $attributes['last_action'] = NULL; $attributes['enabled'] = 'yes'; $attributes['tables_split'] = 2; $attributes['tables_loaded'] = 0; - $attributes['title'] = ''; - $attributes['description'] = ''; + $attributes['title'] = NULL; + $attributes['description'] = NULL; ksort($attributes); $entity_attributes = $this->entity->expose_attributes(); diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php index d8c458bc4..4d079c30f 100644 --- a/engine/tests/objects/sites.php +++ b/engine/tests/objects/sites.php @@ -41,22 +41,22 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { */ public function testElggSiteConstructor() { $attributes = array(); - $attributes['guid'] = ''; + $attributes['guid'] = NULL; $attributes['type'] = 'site'; - $attributes['subtype'] = ''; + $attributes['subtype'] = NULL; $attributes['owner_guid'] = get_loggedin_userid(); $attributes['container_guid'] = get_loggedin_userid(); - $attributes['site_guid'] = 0; + $attributes['site_guid'] = NULL; $attributes['access_id'] = ACCESS_PRIVATE; - $attributes['time_created'] = ''; - $attributes['time_updated'] = ''; - $attributes['last_action'] = ''; + $attributes['time_created'] = NULL; + $attributes['time_updated'] = NULL; + $attributes['last_action'] = NULL; $attributes['enabled'] = 'yes'; $attributes['tables_split'] = 2; $attributes['tables_loaded'] = 0; - $attributes['name'] = ''; - $attributes['description'] = ''; - $attributes['url'] = ''; + $attributes['name'] = NULL; + $attributes['description'] = NULL; + $attributes['url'] = NULL; ksort($attributes); $entity_attributes = $this->site->expose_attributes(); diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php index fe5b48b03..c0566c9b4 100644 --- a/engine/tests/objects/users.php +++ b/engine/tests/objects/users.php @@ -46,26 +46,26 @@ class ElggCoreUserTest extends ElggCoreUnitTest { */ public function testElggUserConstructor() { $attributes = array(); - $attributes['guid'] = ''; + $attributes['guid'] = NULL; $attributes['type'] = 'user'; - $attributes['subtype'] = ''; + $attributes['subtype'] = NULL; $attributes['owner_guid'] = get_loggedin_userid(); $attributes['container_guid'] = get_loggedin_userid(); - $attributes['site_guid'] = 0; + $attributes['site_guid'] = NULL; $attributes['access_id'] = ACCESS_PRIVATE; - $attributes['time_created'] = ''; - $attributes['time_updated'] = ''; - $attributes['last_action'] = ''; + $attributes['time_created'] = NULL; + $attributes['time_updated'] = NULL; + $attributes['last_action'] = NULL; $attributes['enabled'] = 'yes'; $attributes['tables_split'] = 2; $attributes['tables_loaded'] = 0; - $attributes['name'] = ''; - $attributes['username'] = ''; - $attributes['password'] = ''; - $attributes['salt'] = ''; - $attributes['email'] = ''; - $attributes['language'] = ''; - $attributes['code'] = ''; + $attributes['name'] = NULL; + $attributes['username'] = NULL; + $attributes['password'] = NULL; + $attributes['salt'] = NULL; + $attributes['email'] = NULL; + $attributes['language'] = NULL; + $attributes['code'] = NULL; $attributes['banned'] = 'no'; $attributes['admin'] = 'no'; ksort($attributes); -- cgit v1.2.3