inadmissible

Backward compatibility by using is_callable

December 24th, 2005

Some time ago I had to modify one of our custom login handlers for eZ publish to make it update the last visited timestamp. But the datatype also needed to stay backward compatible with older eZ publish releases.

The standard login handler (kernel/classes/datatypes/ezuser/ezuser.php) uses the following function call to update the timestamp:

eZUser::updateLastVisit( $userID );

I could use this too, but what with older releases of eZ publish which do not have the method updateLastVisit in the eZUser class?

Well, there’s a very simple check you can do with the PHP function is_callable:

if ( is_callable( array( 'eZUser', 'updateLastVisit' ) ) )
{
    eZUser::updateLastVisit( $userID );
}

While writing my own code, I’ve discovered that the LDAP and textfile login handlers included in the default eZ publish distribution didn’t update the last visited timestamp. I’ve reported it as a bug on ez.no and it has been fixed one day later.

Entry Filed under: PHP,eZ Publish

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

December 2005
M T W T F S S
    Jan »
 1234
567891011
12131415161718
19202122232425
262728293031  

Most Recent Posts