aboutsummaryrefslogtreecommitdiff
path: root/actions/profile
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2012-10-25 06:52:23 -0700
committerSteve Clay <steve@mrclay.org>2012-10-25 06:52:23 -0700
commit5dc4e276e18f890b0ae03c472db8cc660fe5c13d (patch)
tree55027d428632898b30925c0c2f82517b0a6f2df6 /actions/profile
parent20ea048b510bfb2ae7eb5e26c8a07205887406e2 (diff)
parent2a01ffb27c6509f4b9e32675cf4386d3aae1c713 (diff)
downloadelgg-5dc4e276e18f890b0ae03c472db8cc660fe5c13d.tar.gz
elgg-5dc4e276e18f890b0ae03c472db8cc660fe5c13d.tar.bz2
Merge pull request #383 from jdalsem/#4858-bugs-in-profile-metadata
#4858 bugs in profile metadata
Diffstat (limited to 'actions/profile')
-rw-r--r--actions/profile/edit.php38
1 files changed, 22 insertions, 16 deletions
diff --git a/actions/profile/edit.php b/actions/profile/edit.php
index 8ca60f246..b6d73ff2d 100644
--- a/actions/profile/edit.php
+++ b/actions/profile/edit.php
@@ -51,7 +51,7 @@ foreach ($profile_fields as $shortname => $valuetype) {
if ($valuetype == 'tags') {
$value = string_to_tag_array($value);
}
-
+
$input[$shortname] = $value;
}
@@ -71,24 +71,30 @@ if (sizeof($input) > 0) {
foreach ($input as $shortname => $value) {
$options = array(
'guid' => $owner->guid,
- 'metadata_name' => $shortname
+ 'metadata_name' => $shortname,
+ 'limit' => false
);
elgg_delete_metadata($options);
- if (isset($accesslevel[$shortname])) {
- $access_id = (int) $accesslevel[$shortname];
- } else {
- // this should never be executed since the access level should always be set
- $access_id = ACCESS_DEFAULT;
- }
- if (is_array($value)) {
- $i = 0;
- foreach ($value as $interval) {
- $i++;
- $multiple = ($i > 1) ? TRUE : FALSE;
- create_metadata($owner->guid, $shortname, $interval, 'text', $owner->guid, $access_id, $multiple);
+
+ if(!is_null($value) && ($value !== '')){
+ // only create metadata for non empty values (0 is allowed) to prevent metadata records with empty string values #4858
+
+ if (isset($accesslevel[$shortname])) {
+ $access_id = (int) $accesslevel[$shortname];
+ } else {
+ // this should never be executed since the access level should always be set
+ $access_id = ACCESS_DEFAULT;
+ }
+ if (is_array($value)) {
+ $i = 0;
+ foreach ($value as $interval) {
+ $i++;
+ $multiple = ($i > 1) ? TRUE : FALSE;
+ create_metadata($owner->guid, $shortname, $interval, 'text', $owner->guid, $access_id, $multiple);
+ }
+ } else {
+ create_metadata($owner->getGUID(), $shortname, $value, 'text', $owner->getGUID(), $access_id);
}
- } else {
- create_metadata($owner->getGUID(), $shortname, $value, 'text', $owner->getGUID(), $access_id);
}
}