summaryrefslogtreecommitdiff
path: root/database
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-10-16 16:59:59 +0000
committerDries Buytaert <dries@buytaert.net>2004-10-16 16:59:59 +0000
commit869a91b72eaf85a447e8fd1b78aad51a8b5676cc (patch)
tree35e09f31ddce50325a2895c5ee7cf0e62cea157e /database
parent5a2e0d0377aeffcd29684f20b39ffce15cede2fc (diff)
downloadbrdo-869a91b72eaf85a447e8fd1b78aad51a8b5676cc.tar.gz
brdo-869a91b72eaf85a447e8fd1b78aad51a8b5676cc.tar.bz2
- Patch #11505 by Steven: 'my account' information is not saved.
+ Drupal 4.4 stored profile data in the serialized user->data column. Drupal 4.5 stores profile data in tables (but user->data is still available and used for other stuff, like locale or themes). The update from 4.4 to 4.5 didn't remove the old data from the user->data column properly, because there is no mechanism in user_save to do so (it did try to unset the fields, but this has no effect). + On registration, hook_user('insert') is invoked after saving the data column. This means that any module-specific data is put into the data field. We cannot move hook_user('insert') higher up, because before that point, we do not have a complete $user object yet.
Diffstat (limited to 'database')
-rw-r--r--database/database.mysql2
-rw-r--r--database/database.pgsql2
-rw-r--r--database/updates.inc38
3 files changed, 35 insertions, 7 deletions
diff --git a/database/database.mysql b/database/database.mysql
index 65641a4ec..528ccbaea 100644
--- a/database/database.mysql
+++ b/database/database.mysql
@@ -759,7 +759,7 @@ INSERT INTO permission VALUES (1,'access content',0);
INSERT INTO role (rid, name) VALUES (2, 'authenticated user');
INSERT INTO permission VALUES (2,'access comments, access content, post comments, post comments without approval',0);
-REPLACE variable SET name='update_start', value='s:10:"2004-09-17;"';
+REPLACE variable SET name='update_start', value='s:10:"2004-10-16;"';
REPLACE variable SET name='theme_default', value='s:10:"bluemarine";';
REPLACE blocks SET module = 'user', delta = '0', status = '1';
diff --git a/database/database.pgsql b/database/database.pgsql
index 6e625f74f..ac9e31b99 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -752,7 +752,7 @@ INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1,0,
INSERT INTO system VALUES ('themes/bluemarine/xtemplate.xtmpl','bluemarine','theme','themes/engines/xtemplate/xtemplate.engine',1,0,0);
INSERT INTO system VALUES ('themes/engines/xtemplate/xtemplate.engine','xtemplate','theme_engine','',1,0,0);
-INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2004-09-17";');
+INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2004-10-16";');
INSERT INTO variable(name,value) VALUES('theme_default','s:10:"bluemarine";');
INSERT INTO users(uid,name,mail) VALUES(0,'','');
INSERT INTO users_roles(uid,rid) VALUES(0, 1);
diff --git a/database/updates.inc b/database/updates.inc
index 82940d9ed..396000c80 100644
--- a/database/updates.inc
+++ b/database/updates.inc
@@ -83,7 +83,8 @@ $sql_updates = array(
"2004-08-19" => "update_104",
"2004-09-14" => "update_105",
"2004-09-15" => "update_106",
- "2004-09-17" => "update_107"
+ "2004-09-17" => "update_107",
+ "2004-10-16" => "update_108"
);
function update_32() {
@@ -946,14 +947,16 @@ function update_80() {
if ($account->$old) {
$edit[$new] = $account->$old;
}
- unset($account->$old);
+ // Force deletion of old field
+ $edit[$old] = NULL;
}
// Birthday format change:
if ($edit['birthday']) {
$edit['birthday'] = array('day' => $edit['birthday'], 'month' => $account->profile_birthmonth, 'year' => $account->profile_birthyear);
- unset($account->profile_birthmonth);
- unset($account->profile_birthyear);
+ // Force deletion of old field
+ $edit['profile_birthmonth'] = NULL;
+ $edit['profile_birthyear'] = NULL;
}
// Gender specific changes:
@@ -963,13 +966,18 @@ function update_80() {
// Avatar specific changes:
if ($account->profile_avatar) {
$edit['picture'] = $account->profile_avatar;
+ // Force deletion of old field
+ $edit['profile_avatar'] = NULL;
}
- unset($account->profile_avatar);
// Save the update record:
user_save($account, $edit, 'Personal information');
}
+ // This variable is needed to distinguish betweene 4.5-RC sites which ran a faulty
+ // update_80() and 4.5-final sites. See update_108.
+ variable_set('update_80_fix', true);
+
return $ret;
}
@@ -1873,6 +1881,26 @@ function update_107() {
return $ret;
}
+function update_108() {
+ // This update is needed for 4.5-RC sites, where profile data was not being
+ // wiped from the user->data column correctly because update_80() was faulty.
+ if (!variable_get('update_80_fix', false)) {
+ // The data field needs to be cleared of profile fields.
+ $result = db_query("SELECT uid FROM {users} WHERE data LIKE '%profile%'");
+ while ($uid = db_fetch_object($result)) {
+ $user = user_load(array('uid' => $uid->uid));
+ $unset = array();
+ foreach ($user as $key => $value) {
+ if (substr($key, 0, 8) == 'profile_') {
+ // Fields with a NULL value are wiped from the data column.
+ $unset[$key] = NULL;
+ }
+ }
+ user_save($user, $unset);
+ }
+ }
+}
+
function update_sql($sql) {
$edit = $_POST["edit"];
$result = db_query($sql);