Doctrine 1
  1. Doctrine 1
  2. DC-298

Doctrine_Cache_Driver : array_search() expects parameter 2 to be array, boolean given at line 283

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-RC1
    • Fix Version/s: 1.2.1
    • Component/s: Caching
    • Labels:
      None

      Description

      Doctrine_Cache_Driver::fetch() is supposed to return a string, but an array_search() is made on it by Doctrine_Cache_Driver::_deleteKey() (at line 283).

        Activity

        Hide
        Jonathan H. Wage added a comment -

        I don't quite understand. Can you explain more?

        Show
        Jonathan H. Wage added a comment - I don't quite understand. Can you explain more?
        Hide
        Jonathan H. Wage added a comment -

        Reading your description it doesn't make any sense. Re-open if you have a better more clear description of the problem.

        Show
        Jonathan H. Wage added a comment - Reading your description it doesn't make any sense. Re-open if you have a better more clear description of the problem.
        Hide
        Benoît Guchet added a comment - - edited

        It's not very complicated :

        In Doctrine_Cache_Driver::_deleteKey, you do array_search() with the array $keys as haystack:

        $keys = $this->fetch($this->_cacheKeyIndexKey);
        $key = array_search($key, $keys);

        But $keys is a string, because Doctrine_Cache_Driver::fetch returns a string (or false) :

        /**

        • Fetch a cache record from this cache driver instance
          *
        • @param string $id cache id
        • @param boolean $testCacheValidity if set to false, the cache validity won't be tested
        • @return string cached datas (or false)
          */
          public function fetch($id, $testCacheValidity = true)

        You can't make an array_search on a string.

        I can't be more clear

        edit : You may tell me that the PHPdoc is wrong : but the problem still appears when ::fetch returns false.

        Show
        Benoît Guchet added a comment - - edited It's not very complicated : In Doctrine_Cache_Driver::_deleteKey, you do array_search() with the array $keys as haystack: $keys = $this->fetch($this->_cacheKeyIndexKey); $key = array_search($key, $keys); But $keys is a string, because Doctrine_Cache_Driver::fetch returns a string (or false) : /** Fetch a cache record from this cache driver instance * @param string $id cache id @param boolean $testCacheValidity if set to false, the cache validity won't be tested @return string cached datas (or false) */ public function fetch($id, $testCacheValidity = true) You can't make an array_search on a string. I can't be more clear edit : You may tell me that the PHPdoc is wrong : but the problem still appears when ::fetch returns false.
        Hide
        Jonathan H. Wage added a comment -

        The api documentation is wrong, fetch always returns the data structure that was originally stored. So in this case it is an array.

        Show
        Jonathan H. Wage added a comment - The api documentation is wrong, fetch always returns the data structure that was originally stored. So in this case it is an array.
        Hide
        Benoît Guchet added a comment -

        Ok i've anticipated this answer

        So Cf. edit of my last comment.

        Show
        Benoît Guchet added a comment - Ok i've anticipated this answer So Cf. edit of my last comment.
        Hide
        Jonathan H. Wage added a comment -

        I updated the API doc blocks.

        Show
        Jonathan H. Wage added a comment - I updated the API doc blocks.
        Hide
        Benoît Guchet added a comment - - edited

        Sorry, I reopen this issue again because I still encounter it.

        I've watched it deeper to make it reproductible :

        I'm using Doctrine_Cache_Array.
        The problem simply appears when you try to delete a cache entry that does not exist.

        example :

        $cache = new Doctrine_Cache_Array();
        $cache->delete(45);

        Show
        Benoît Guchet added a comment - - edited Sorry, I reopen this issue again because I still encounter it. I've watched it deeper to make it reproductible : I'm using Doctrine_Cache_Array. The problem simply appears when you try to delete a cache entry that does not exist. example : $cache = new Doctrine_Cache_Array(); $cache->delete(45);
        Hide
        Benoît Guchet added a comment -

        Patch to Doctrine_Cache_Array::_doDelete() so that it returns false if the entry does not exist.

        Show
        Benoît Guchet added a comment - Patch to Doctrine_Cache_Array::_doDelete() so that it returns false if the entry does not exist.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Benoît Guchet
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: