• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed  Bug in library\XenForo\Model\DataRegistry.php

Yoskaldyr

Well-known member
#1
I've tried to use file-cache and after enabling it in the config.php I've found a problem - forum script recreates cache after every request. So I went to look where the problem is, and (surprise, surprise =)) I've found it in the XenForo_Model_DataRegistry class in the method getMulti - there is a unset function call, which should delete an array item, but there is wrong key used to do this. So there is a quickfix:
find
PHP:
        $cache = $this->_getCache(true);
        $dbItemNames = $itemNames;
        $data = array();

        foreach ($itemNames AS $itemName)
        {
            $cacheData = ($cache ? $cache->load($this->_getCacheEntryName($itemName)) : false);
            if ($cacheData !== false)
            {
                $data[$itemName] = $cacheData;
                unset($dbItemNames[$itemName]);
            }
        }
Replace with
PHP:
        $cache = $this->_getCache(true);
        $dbItemNames = array();
        $data = array();

        foreach ($itemNames AS $itemName)
        {
            $cacheData = ($cache ? $cache->load($this->_getCacheEntryName($itemName)) : false);
            if ($cacheData !== false)
            {
                $data[$itemName] = $cacheData;
            }
            else
            {
                 $dbItemNames[] = $itemName;
            }
        }