-
Bug
-
Resolution: Fixed
-
3.0.5
-
None
-
PHP Environment: 5.2.9
Database: PosgreSQL 8.1.11 and 8.3.7
If you add a custom profile field, and generate a backup of the schema for
phpbb_profile_fields_data, the table definition will have a syntax error, for
example,
-- Table: phpbb_profile_fields_data
|
DROP TABLE phpbb_profile_fields_data;
|
CREATE TABLE phpbb_profile_fields_data(
|
user_id int4 DEFAULT 0 NOT NULL,
|
pf_some_number int8 DEFAULT ,
|
pf_some_boolean int2 DEFAULT ,
|
pf_some_text varchar(255) DEFAULT ,
|
CONSTRAINT phpbb_profile_fields_data_pkey PRIMARY KEY (user_id),
|
CONSTRAINT phpbb_profile_fields_data_user_id_check CHECK (user_id >= 0)
|
);
|
COMMIT;
|
Note that the custom fields have a default indicated, but no default value is
specified. This happens whether or not I specify a default for the field, and
the datatype does not seem to matter.
Digging into the code in acp_database.php [around line 1196]
if (isset($row['rowdefault']))
|
{
|
$line .= ' DEFAULT ' . $row['rowdefault'];
|
}
|
It seems $row['rowdefault'] is being set, but to the empty string,
and irrespective of the default value.
Running the queries on lines 1140 and 1154 manualy produces the expected
(correct) results, so I'm thinking its got something to do with the php
and its kooky boolean logic. My guess its got something to do with lines
1159 to 1168
$def_res = $db->sql_query($sql_get_default);
|
|
|
if (!$def_res)
|
{
|
unset($row['rowdefault']);
|
}
|
else
|
{
|
$row['rowdefault'] = $db->sql_fetchfield('rowdefault', false, $def_res);
|
}
|
$def_res is 'true' when there is no result, and $db->sql_fetchfield() is
returning an empty string. And when there is a result,
$db->sql_fetchfield() is also returning an empty string. Ouch!

