R
ragtek
Guest
ATM it only checks if the class & method exists.
I've made a stupid mistake and insterted the extended class & method instead of the code listener callback names.
I used
instead of
this was valid and after it was saved, my board stopped working and i got a exception on loading every page.......
i added now a validation to check if the method is static to the preSave method in the event listener dw
and now it's throwing an error before it gets saved, instead of saving it and stopping the board
it's no big deal for us developers,but it's not necessary to disable the event listener system and delete the listener if it also checks if the callback is static
I've made a stupid mistake and insterted the extended class & method instead of the code listener callback names.
I used
PHP:
class Ragtek_C1002_Model_UserIgnore extends
XenForo_Model_UserIgnore
{
public function ignoreUsers($userId, $ignoredUserIds)
{
return parent::ignoreUsers($userId, $ignoredUserIds);
}
}
PHP:
class Ragtek_C1002_StaticMethods{
public static function listener($class, &$extend){
if ($class == 'XenForo_Model_UserIgnore'){
$extend[] = 'Ragtek_C1002_Model_UserIgnore';
}
}
this was valid and after it was saved, my board stopped working and i got a exception on loading every page.......
i added now a validation to check if the method is static to the preSave method in the event listener dw
PHP:
protected function _preSave()
{
if ($this->isChanged('callback_class') || $this->isChanged('callback_method'))
{
$class = $this->get('callback_class');
$method = $this->get('callback_method');
if (!XenForo_Application::autoload($class) || !method_exists($class, $method))
{
$this->error(new XenForo_Phrase('please_enter_valid_callback_method'), 'callback_method');
}
//ragtek change
$ref = new ReflectionMethod($class, $method);
if (!$ref->isStatic()){
$this->error('no static method');
}
//ragtek change end
}
}
it's no big deal for us developers,but it's not necessary to disable the event listener system and delete the listener if it also checks if the callback is static
Upvote
1