Zend Framework

Argument 1 of Zend_Cache_Core::setBackend() should implement Zend_Cache_Backend_Interface, not Zend_Cache_Backend

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Not an Issue
  • Affects Version/s: 1.9.4
  • Fix Version/s: None
  • Component/s: Zend_Cache
  • Labels:
    None

Description

Code

$backend = Zend_Cache::_makeBackend($options['backend'], $options['backendOptions']);
$backend = new Dklab_Cache_Backend_Profiler($backend, array("R00_Profiler_Cache", "profilerCallback"));
$cache =  Zend_Cache::factory($frontend,
                              $backend,
                              array_merge($options['frontendOptions'], $frontendOptions));

Result

Catchable fatal error: Argument 1 passed to Zend_Cache_Core::setBackend() must be an instance of Zend_Cache_Backend, instance of Dklab_Cache_Backend_Profiler given, called in D:\work\meetster\library\Zend\Cache.php on line 110 and defined in D:\work\meetster\library\Zend\Cache\Core.php on line 168

Also

class Dklab_Cache_Backend_Profiler implements Zend_Cache_Backend_Interface  {
...
}
// http://dklab.ru/lib/Dklab_Cache/

Activity

Hide
Ramon Henrique Ornelas added a comment -

Your problem with the param passed, the Type Hinting of the Zend_Cache_Core::setBackend().

public function setBackend(Zend_Cache_Backend $backendObject)

try

class Dklab_Cache_Backend_Profiler extends Zend_Cache_Backend implements Zend_Cache_Backend_Interface

Show
Ramon Henrique Ornelas added a comment - Your problem with the param passed, the Type Hinting of the Zend_Cache_Core::setBackend().
public function setBackend(Zend_Cache_Backend $backendObject)
try class Dklab_Cache_Backend_Profiler extends Zend_Cache_Backend implements Zend_Cache_Backend_Interface
Hide
Valentin Golev added a comment -

Ramon Henrique Ornelas,

I don't think it's a good way. Why is there an interface if we still need to extend an object?

But, then I changed to:

public function setBackend(Zend_Cache_Backend_Interface $backendObject)

everything was fine

Show
Valentin Golev added a comment - Ramon Henrique Ornelas, I don't think it's a good way. Why is there an interface if we still need to extend an object? But, then I changed to:
public function setBackend(Zend_Cache_Backend_Interface $backendObject)
everything was fine
Hide
Valentin Golev added a comment -

Ramon Henrique Ornelas,

I don't think it's a good way. Why is there an interface if we still need to extend an object?

But, then I changed to:

public function setBackend(Zend_Cache_Backend_Interface $backendObject)

everything was fine

Show
Valentin Golev added a comment - Ramon Henrique Ornelas, I don't think it's a good way. Why is there an interface if we still need to extend an object? But, then I changed to:
public function setBackend(Zend_Cache_Backend_Interface $backendObject)
everything was fine
Show
Ramon Henrique Ornelas added a comment - Agree, proposal of the refactoring in http://framework.zend.com/wiki/display/ZFPROP/Zend_Cache+refactoring+-+Marc+Bennewitz
Hide
Valera Leontyev added a comment -

Why Zend_Cache_Backend used in Zend_Cache_Core::setBackend(Zend_Cache_Backend $backendObject) and what the reason of creation Zend_Cache_Backend_Interface if it isn't used?

I realy need to pass Zend_Cache_Backend_Interface in setBackend(), not Zend_Cache_Backend.

Isn't it a bug?

Show
Valera Leontyev added a comment - Why Zend_Cache_Backend used in Zend_Cache_Core::setBackend(Zend_Cache_Backend $backendObject) and what the reason of creation Zend_Cache_Backend_Interface if it isn't used? I realy need to pass Zend_Cache_Backend_Interface in setBackend(), not Zend_Cache_Backend. Isn't it a bug?
Hide
Ramon Henrique Ornelas added a comment - - edited

Valera

This changes could cause break BC.

Show
Ramon Henrique Ornelas added a comment - - edited Valera This changes could cause break BC.

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: