Fatal Error: The statement of EasyBlogTableMediaManager :: bind () must be compatible with JTableInterface :: bind ()

advertisements

I have a problem with easyblog. When I try to open a blog entry through backend I get the following error:

Fatal error: Declaration of EasyBlogTableMediaManager::bind() must be compatible with that of JTableInterface::bind() in /home/mysit/public_html/localadvertiser/administrator/components/com_easyblog/tables/mediamanager.php on line 46

I am running Joomla 3.2.5 The error reporting is set to 'maximum'. Any idea what the issue could be here?

This is file where the error occurs

class EasyBlogTableMediaManager extends EasyBlogTable
{
    var $id     = null;
    var $path   = '';
    var $type   = '';
    var $params = '';
    function __construct(& $db )
    {
        parent::__construct( '#__easyblog_mediamanager' , 'id' , $db );
    }
    public function bind( $data = array() )
    {
        return parent::bind( $data );
    }
    public function load( $path , $type )
    {
        $db     = EasyBlogHelper::db();
        $query  = 'SELECT * FROM ' . EasyBlogHelper::getHelper( 'SQL' )->nameQuote( $this->_tbl );
        $query  .= ' WHERE ' . EasyBlogHelper::getHelper( 'SQL' )->nameQuote( 'path' ) . '=' . $db->Quote( $path );
        $query  .= ' AND ' . EasyBlogHelper::getHelper( 'SQL' )->nameQuote( 'type' ) . '=' . $db->Quote( $type );
        $db->setQuery( $query );
        $obj    = $db->loadObject();
        return parent::bind( $obj );
    }
}


TLDR

Yes I think the error is occurring because you have error reporting set to maximum, which is probably forcing a STRICT mode, if you set the level to None it should work fine, as this will set display_errors to 0. This is also, probably, an indication you're using PHP 5.4 or higher on your server (A Good Thing™).

Longer & more precise:

As the error states the Declaration of EasyBlogTableMediaManager::bind() must be compatible (i.e. the same/match) with the original declaration in the JTableInterface class.

This tells us that EasyBlogTableMediaManager which extends EasyBlogTable has as a parent class going back to JTable (found at /libraries/joomla/table/table.php) which is defined as:

abstract class JTable extends JObject implements JObservableInterface, JTableInterface

You will notice that it implements JTableInterface, which means that the original JTable->bind() must match the interface declaration of JTableInterface (found at /libraries/joomla/table/interface.php) you will see that it's defined in the interface file as:

public function bind($src, $ignore = array());

When you compare that to the declaration in the EasyBlogTableMediaManager class you've provided:

public function bind( $data = array() )
{
    return parent::bind( $data );
}

You can see the method signatures are different (i.e. the EasyBlog bind() method is only defining a single parameter $data). So, quoting the PHP documentation for interface linked previously:

Note: The class implementing the interface must use the exact same method signatures as are defined in the interface. Not doing so will result in a fatal error.

Between Joomla 2.5.x and Joomla 3.x several method signatures changed, given that it's a major version number change this is to be expected and developers can produce separate extension builds for each version to avoid this issue but it does introduce an extra layer of support.

If you need Error Reporting on Maximum

You may be able to fix it by simply changing the method signature to this:

public function bind( $data = array(), $ignore = array())
{
    return parent::bind( $data );
}

However, that may result in the error moving further up the class hierarchy, and will probably re-appear if you update the version of EasyBlog (as your change will be over-written). It's probably best to take it up with the developer of EasyBlog.