Do not store profile modification of null fields.
authorStéphane Jacob <sj@m4x.org>
Sun, 6 Feb 2011 20:46:27 +0000 (21:46 +0100)
committerStéphane Jacob <sj@m4x.org>
Sun, 6 Feb 2011 20:46:27 +0000 (21:46 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
modules/profile/page.inc.php

index 9501b58..1323e86 100644 (file)
@@ -306,12 +306,14 @@ abstract class ProfilePage implements PlWizardPage
         $user = S::user();
         if ($owner->isActive()) {
             foreach ($changedFields as $field => $values) {
-                XDB::execute('INSERT INTO  profile_modifications (pid, uid, field, oldText, newText, type, timestamp)
-                                   VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, NOW())
-                  ON DUPLICATE KEY UPDATE  uid = VALUES(uid), oldText = IF(VALUES(type) != type, VALUES(oldText), oldText),
-                                           newText = VALUES(newText), type = VALUES(type), timestamp = NOW()',
-                             $this->pid(), $user->id(), Profile::$descriptions[$field], $values[0], $values[1],
-                             ($owner->id() == $user->id()) ? 'self' : 'third_party');
+                if (!is_null($field)) {
+                    XDB::execute('INSERT INTO  profile_modifications (pid, uid, field, oldText, newText, type, timestamp)
+                                       VALUES  ({?}, {?}, {?}, {?}, {?}, {?}, NOW())
+                      ON DUPLICATE KEY UPDATE  uid = VALUES(uid), oldText = IF(VALUES(type) != type, VALUES(oldText), oldText),
+                                               newText = VALUES(newText), type = VALUES(type), timestamp = NOW()',
+                                 $this->pid(), $user->id(), Profile::$descriptions[$field], $values[0], $values[1],
+                                 ($owner->id() == $user->id()) ? 'self' : 'third_party');
+                }
             }
         }
         return true;