Giter Club home page Giter Club logo

Comments (3)

huguesalary avatar huguesalary commented on July 21, 2024

I second that bug.

All the calls:
(string) ($config->descend('host') ?: '127.0.0.1'); yield an unwanted result.

$config->descend('host') will always return true, even if the <host></host> node is empty.

This causes a serious problem here:

$this->_useLocking = defined('CM_REDISSESSION_LOCKING_ENABLED')
                    ? CM_REDISSESSION_LOCKING_ENABLED
                    : ! ($config->disable_locking ?: self::DEFAULT_DISABLE_LOCKING);

! ($config->disable_locking ?: self::DEFAULT_DISABLE_LOCKING) always returns false. Which means that _useLocking is always false, which means that locking is never used.

Here's an example for different values of the <disable_locking> node:
<disable_locking>0</disable_locking> ---> ! ($config->disable_locking ?: self::DEFAULT_DISABLE_LOCKING) // false
<disable_locking>1</disable_locking> ---> ! ($config->disable_locking ?: self::DEFAULT_DISABLE_LOCKING) // false
<disable_locking>true</disable_locking> ---> ! ($config->disable_locking ?: self::DEFAULT_DISABLE_LOCKING) // false
<disable_locking>false</disable_locking> ---> ! ($config->disable_locking ?: self::DEFAULT_DISABLE_LOCKING) // false

from cm_redissession.

colinmollenhour avatar colinmollenhour commented on July 21, 2024
(string) ($config->descend('host') ?: '127.0.0.1');

The first expression to be evaluated here is $config->descend('host'). If no node exists this is falsey so the string '127.0.0.1' is returned. If a node does exist the ternary expression evaluates to the node which is then cast to a string. If a user specifies an empty node then an empty string must be what the user wants, right? I suppose it is subjective, but if you want to use the defaults then you should just not specify those nodes at all. If you do specify nodes then it will take them literally, for better or for worse.

However, the $config->descend('disable_locking') is cast directly to a bool instead of to a string first and then a bool so you are right that this is a bug. Locking is enabled if no "disable_locking" node is specified, though.

Thanks, both for the issue report.

from cm_redissession.

huguesalary avatar huguesalary commented on July 21, 2024

If a user specifies an empty node then an empty string must be what the user wants, right? I suppose it is subjective

I hadn't seen it that way, it's definitely subjective. After thinking more about it, I can see that a user may want to supplie an empty string value (even if, in the case of the <host> node for example, it makes absolutely no sense). So, although not necessarily the most intuitive, your approach is the most flexible one.

Thanks for the bugfix!

from cm_redissession.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.