Skip to content

non-tag code in save() is never followed #8

@thompsa

Description

@thompsa
 public function save($data, $id, $tags = array(), $specificLifetime = false)
    {
        if (!$this->_redis)
            return false;
        $lifetime = $this->getLifetime($specificLifetime);
        if (!$tags || !count($tags))
            $tags = array('');
        if (is_string($tags))
            $tags = array($tags);
        if (!count($tags)) {
        ...

In this block of code if tags is not set or an empty array it will always be set to an array containing one empty string. This means that the code block for set/setex is never followed when no tags are present.

Change to initialising it to an empty array. This is still slightly redundant as the function declaration has a default value for $tags.

--- Redis.php
+++ Redis.php
@@ -184,7 +184,7 @@ 
         $lifetime = $this->getLifetime($specificLifetime);

         if (!$tags || !count($tags))
-            $tags = array('');
+            $tags = array();
         if (is_string($tags))
             $tags = array($tags);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions