Bug tracker

This ticket has been moved to our new tracker. Open Ticket PHPBB3-8543 now.

backup generates bad table definition for phpbb_profile_fields_data (fix completed in vcs)

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,

Code: Select all
-- 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]
Code: Select all
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
Code: Select all
$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!

Comments / History

Assigned ticket to user "bantu"

Action performed by bantu (3.0 Release Manager) on Aug 2nd 2009, 18:30

Changed ticket status from "New" to "Reviewed"

Action performed by bantu (3.0 Release Manager) on Aug 2nd 2009, 18:30

Changed ticket status from "Reviewed" to "Fix in progress"

Action performed by bantu (3.0 Release Manager) on Aug 3rd 2009, 22:14

Posted by bantu (3.0 Release Manager) on Aug 3rd 2009, 22:14

Hi tartansandal,

here is an updated acp_database.php file and a diff. Could you please try one of those and see if the problem got fixed? :-)

Thanks,
bantu.
bug-48955.diff (1.8 KB), acp_database.php (55.03 KB)

Edited post #173705

Action performed by bantu (3.0 Release Manager) on Aug 3rd 2009, 22:14

Assigned ticket to user "Acyd Burn"

Action performed by bantu (3.0 Release Manager) on Aug 3rd 2009, 22:16

Posted by tartansandal on Aug 4th 2009, 02:51

Thanks for the quick response bantu :-)

The patch works for me, and I have successfully
use the backup feature to move a snapshot to my test server.

Cheers!

tartansandal

Assigned ticket to user "bantu"

Action performed by bantu (3.0 Release Manager) on Aug 5th 2009, 12:55

Linked ticket with changeset: r9928

Action performed by bantu (3.0 Release Manager) on Aug 5th 2009, 13:05

Changed ticket status from "Fix in progress" to "Fix completed in SVN"

Action performed by bantu (3.0 Release Manager) on Aug 5th 2009, 13:14

Ticket details

Related SVN changesets