getSettings should not return undefined settings, it should set it to NULL

Bug #932577 reported by Adrian Liechti
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PHPDevShell
Fix Released
Low
TitanKing

Bug Description

When i try to make a configuration to set some settings, but the settings do not exist at this time. I must set the settings Like this to handle it:

$setting = $this->db->getSettings(array('cfg1', 'cfg2'), 'cfgTest');
$setting2 = array('cfg1'=>NULL, 'cfg2'=>NULL);

$setting = array_merge($setting2, $setting);

Otherwise, it destroys the layout of the page, when i do not handle it like this.

Revision history for this message
Greg (gregfr) wrote :

I would say that your script breaks when you're trying to use your settings variables.

The normal working of PHP is to emit a warning when the code is using an undefined variable, which may be caught by the framework as an error (depending on your configuration).

It's actually a good thing (your code should use undefined variables and should not generate warnings), and the way you dealt with it is good programming.

I think it's not a problem with the framework.

Revision history for this message
Adrian Liechti (jahweh) wrote :

Why the script may break? it is tested :)

Now you mean that this is a good way to work arround the problem, but it is a work arround in my opinion and does not solve the problem really.

Some other example:
...Setting cfg1 is set, but cfg2 is not set...
When i need some settings from you, i ask you: "hey i need this settings: cfg1 and cfg2".
Then you give me the answer: "here are the settings: cfg1 is 'someting' and cfg2 is not set".
But when i ask the getSettings Method it gives me some answer: "here are the settings: cfg1"

Now you know what I mean right?

Revision history for this message
TitanKing (titan-phpdevshell) wrote :

Hi Adrian,

What Greg is trying to say is that the behaviour is normal for none-assigned variables.
However, digging deeper I found what you are referring too, a fix will be commited soon.

Regards,
Jason

Changed in phpdevshell:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → TitanKing (titan-phpdevshell)
milestone: none → 3.1.4-stable
Revision history for this message
TitanKing (titan-phpdevshell) wrote :

Attached please find patch.

Changed in phpdevshell:
status: Confirmed → Fix Committed
Revision history for this message
TitanKing (titan-phpdevshell) wrote :
Changed in phpdevshell:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.