Forums / Developer / Preferences Code

Preferences Code

Author Message

Rob Clews

Monday 05 January 2004 3:47:36 am

in kernel/classes/ezpreferences.php there is the following:

$existingRes = $db->arrayQuery( "SELECT * FROM ezpreferences WHERE user_id = $userID" );

if ( count( $existingRes ) > 0 )
[...]
$query = "UPDATE ezpreferences SET value='$value' WHERE id = $prefID AND name='$name'";

Unless I'm being stupid here, my understanding of the function is as follows. If there is not setting for $name in the database then insert it, if it exists update it. So surely that select is incorrect because if you have any preferences for the current user then count($existingRes) will be > 0, although the pref you are trying to save may not exist in the db.

Ultimately, this only allows one preference to ever be set?

Rob Clews

Monday 05 January 2004 3:48:41 am

Probably wasn't clear, but shouldn't the select query be:

$existingRes = $db->arrayQuery( "SELECT * FROM ezpreferences WHERE user_id = $userID AND name='$name'" );

Paul Borgermans

Monday 05 January 2004 5:01:46 am

Rob, This was fixed a while ago, on 2003-11-27 (3.2-4 and 3.3-1 should be OK)

See also this bug report:

http://ez.no/developer/ez_publish_3/bug_reports/ezpreferences_only_one_variable_can_be_stored_in_the_database_for_each_user

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans