Jump to content

Bug in hasKey()? Unable to set Configuration key-value


Perfecticus

Recommended Posts

Hello,

 

I've been trying to figure out why I'm unable to store certain configuration values.

By debugging each step of Configuration.php I noticed something strange.

 

I'm running 1.6.1.7 by the way.

 

The reason why my settings arent being saved is because hasKey() returns true

even though there are no row in the configuration table with the key name I specify.

 

For some reason, the one value which contains a longer string value (dateformat)

saves perfectly fine, whereas the rest (being binary 0/1 values) will not save to db.

 

The debugging I did was to prior to executing updateValue(key,val) - print out the status of

hasKey() and getIdByName(), as there wont be any insertion if hasKey() is true.

 

Am I doing something wrong here or what is going on?

 

Note:

If I alter line 412 of Configuration.php to check if stored_value is set IT WORKS:

            // If key already exists, update value
            if (Configuration::hasKey($key, $lang, $id_shop_group, $id_shop)) {

into:

            // If key already exists, update value
            if (stored_value !== false) {

Debug log

Configuration::getIdByName(HANSA_CHECKOUT_SHIPDATE) = 0
Configuration::hasKey(HANSA_CHECKOUT_SHIPDATE) = 1
Executing Configuration::updateValue('HANSA_CHECKOUT_SHIPDATE','1')

Configuration::getIdByName(HANSA_CHECKOUT_UPLOAD) = 0
Configuration::hasKey(HANSA_CHECKOUT_UPLOAD) = 1
Executing Configuration::updateValue('HANSA_CHECKOUT_UPLOAD','1')

Configuration::getIdByName(HANSA_CHECKOUT_PHONE) = 0
Configuration::hasKey(HANSA_CHECKOUT_PHONE) = 1
Executing Configuration::updateValue('HANSA_CHECKOUT_PHONE','1')

Configuration::getIdByName(HANSA_CHECKOUT_PARTDEL) = 0
Configuration::hasKey(HANSA_CHECKOUT_PARTDEL) = 1
Executing Configuration::updateValue('HANSA_CHECKOUT_PARTDEL','1')

Configuration::getIdByName(HANSA_CHECKOUT_DATEFORMAT) = 465
Configuration::hasKey(HANSA_CHECKOUT_DATEFORMAT) = 1
Executing Configuration::updateValue('HANSA_CHECKOUT_DATEFORMAT','yy-mm-dd')
Link to comment
Share on other sites

After further investigation, I realized something.

 

In my default settings I was using default values using (true/false), which resulted in

Configuration::updateValue() to add the settings to cache, but not to table, which in turn

resulted in me not being able to later insert updated values.

 

tldr:

Configuration::updateValue() should not add to cache if nothing was inserted.

 

Calling for example:

Configuration::updateValue('mykey', false);

Will NOT insert into configuration-table,

but will add the key to cache, making the configuration-key unmodifiable in db.

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...