Fix r66267, make hook code consistent with documentation, fix E_NOTICE