'on_page_delete' event

Permalink
I've been playing around with different events and I'm noticing that the 'on_page_delete' event only fires when you delete the page by visiting it, clicking "Edit Page"->"Move/Delete"->"Delete Page" (button on bottom right).

If you delete the page through any of sitemap views, nothing happens.

The on_page_add event fires in both circumstances and appears to work normally.

/config/site_events.php
<?php
Events::extend('on_page_delete',   'CustomHooks', 'refreshNav', 'models/custom_hooks.php', array('delete'));
Events::extend('on_page_add',      'CustomHooks', 'refreshNav', 'models/custom_hooks.php', array('add'));
?>


/models/custom_hooks.php
<?php defined('C5_EXECUTE') or die("Access Denied.");
class CustomHooks {
   /**
   * Hooks into main page events and updates the tab nav HTML cache
   *
   * @param object $objPage - The page object passed by the event
   */
   public function refreshNav($objPage, $args){   
      $db = Loader::db();
      $q = "INSERT INTO test (event, page_name, page_id) VALUES (?, ?, ?)";
      $v = array($args, $objPage->getCollectionName(), $objPage->cID);
      $db->query($q, $v);
   }
}
?>



What am I missing?

Thanks :)

EDIT: Seems this problem was an unresolved thread (http://www.concrete5.org/community/forums/customizing_c5/page-type-events/) and is a valid bug (http://www.concrete5.org/developers/bugs/5-4-1-1/on_page_delete-doesnand039t-fire-from-the-site-map/)

beebs93
 
andrew replied on at Permalink Best Answer Reply
andrew
I think this is fixed in our latest dev branch. Try the source hosted at github.com. I think this is due to the fact that the startup/tools.php script is being included BEFORE site_events.php, and the delete through sitemap takes place in that tools startup script. In github we've switched the order.
beebs93 replied on at Permalink Reply
beebs93
Thanks for the update!