HeadStand Posted October 23, 2018 Posted October 23, 2018 I have a stupidly simple code hook running on \IPS\Dispatcher\Front: /** * Init * * @return void */ public function init() { parent::init(); if( !\IPS\Request::i()->isAjax() && $this->application->directory != 'audit' ) { \IPS\audit\Logs\Views::logPageView(); } } That is literally the entire hook. But it's not doing anything. Flat out not working. I added logging like this: /** * Init * * @return void */ public function init() { \IPS\Log::log( 'I AM HERE', 'aaa' ); parent::init(); \IPS\Log::log( 'after init', 'aaa' ); if( !\IPS\Request::i()->isAjax() && $this->application->directory != 'audit' ) { \IPS\Log::log( 'logging this view', 'aaa' ); \IPS\audit\Logs\Views::logPageView(); \IPS\Log::log( 'view was logged', 'aaa' ); } } And the system logs are completely empty. I'm not even getting "I AM HERE". Which leads me to believe that the code is simply not being called at all. Contents of the hooks.json file in my application data folder: { "AuditDispatcherFront": { "type": "C", "class": "\\IPS\\Dispatcher\\Front" } } You can see the class is spelled correctly and everything. The code works perfectly in my dev environment but doesn't work on the client's server. I've never encountered anything like this before and for the life of me I can't understand it. I also tried disabling all 3rd party apps and plugins on the client's server, except for this one, and it still doesn't work. So I've ruled out a conflict. Just in case there was something fluky going on, I checked their core_hooks table and there are no other hook on the Dispatcher class. Anyone ever see something like this before? @bfarber? @Daniel F? Any suggestions would be appreciated. Client is running 4.2, if that makes a difference. I've tested it on a local 4.2 and it's fine here.... just totally not working there. 😞
Daniel F Posted October 23, 2018 Posted October 23, 2018 The class and the method can also definitely be hooked, just tested it myself and it works. Stupid question, but since it's included in the core_hooks table, is it also present in the plugins/hooks.php file? I've seen this in an ticket years ago, where the hooks.php file wasn't rebuilt successful.
HeadStand Posted October 23, 2018 Author Posted October 23, 2018 43 minutes ago, Daniel F said: The class and the method can also definitely be hooked, just tested it myself and it works. Stupid question, but since it's included in the core_hooks table, is it also present in the plugins/hooks.php file? I've seen this in an ticket years ago, where the hooks.php file wasn't rebuilt successful. I'll ask the client to check, but I'm not sure if he has that kind of access.
bfarber Posted October 23, 2018 Posted October 23, 2018 You're "I AM HERE" log should occur no matter what. The rest wouldn't if it was a guest viewing a cached page, but I can't explain why you aren't seeing that log entry with the details given unfortunately. I'd agree with Daniel, check hooks.php to make sure it's loading. You may also need to debug in the cached file that's written to disk and executed (code gets wrapped in a try/catch which will automatically call the parent method, so you may need to verify there's no sort of exception occurring there for instance, no PHP errors logged, etc.).
Massimo Citterio Posted November 19, 2018 Posted November 19, 2018 I'm having the exact issue. Hooks were working perfectly fine but now none of them work. Given that my current app structure is this: Where should I add the hooks.php file for debugging? EDIT: is there a way to see that hooks are failing loading and why? Throwing exceptions purposely won't work. Thanks, Massimo
HeadStand Posted November 19, 2018 Author Posted November 19, 2018 On 10/23/2018 at 11:24 AM, bfarber said: You're "I AM HERE" log should occur no matter what. The rest wouldn't if it was a guest viewing a cached page, but I can't explain why you aren't seeing that log entry with the details given unfortunately. I'd agree with Daniel, check hooks.php to make sure it's loading. You may also need to debug in the cached file that's written to disk and executed (code gets wrapped in a try/catch which will automatically call the parent method, so you may need to verify there's no sort of exception occurring there for instance, no PHP errors logged, etc.). Update on this issue: It looks like the hooks.php file did not include my classes. I have a suspicion that the permissions on the server are messed up and therefore hooks.php couldn't be updated.
Daniel F Posted November 19, 2018 Posted November 19, 2018 I've improved this for IPS 4.4.0 🙂 Application and plugin installation will fail if hooks are present and if the file isn't writable
Massimo Citterio Posted November 20, 2018 Posted November 20, 2018 19 hours ago, HeadStand said: Update on this issue: It looks like the hooks.php file did not include my classes. I have a suspicion that the permissions on the server are messed up and therefore hooks.php couldn't be updated. For clients with the cloud plan, how would they fix that? We have no access to this hooks.php, so any other extension in the store that uses hooks is basically useless if this hooks.php can't update itself. I tried your simple code hook in the first post aswell.
Daniel F Posted November 20, 2018 Posted November 20, 2018 55 minutes ago, Massimo Citterio said: For clients with the cloud plan, how would they fix that? We have no access to this hooks.php, so any other extension in the store that uses hooks is basically useless if this hooks.php can't update itself. I tried your simple code hook in the first post aswell. Hi, I'm working on your ticket right now and will get back to you as soon as we find and fix the issue 🙂
HeadStand Posted November 20, 2018 Author Posted November 20, 2018 1 hour ago, Massimo Citterio said: For clients with the cloud plan, how would they fix that? We have no access to this hooks.php, so any other extension in the store that uses hooks is basically useless if this hooks.php can't update itself. By opening a ticket. 😉 Also, the odds are that if you're running a cloud plan, the permissions are probably fine.
Massimo Citterio Posted November 21, 2018 Posted November 21, 2018 17 hours ago, HeadStand said: By opening a ticket. 😉 Also, the odds are that if you're running a cloud plan, the permissions are probably fine. I did. @Daniel F fixed it! 🙂
bfarber Posted November 21, 2018 Posted November 21, 2018 Yes, we've identified the issue (which affected more than just one or two clients, although it was still isolated) and have resolved it. If the client opens a ticket we can resynchronize their files to resolve the issue....or you can simply disable a plugin and re-enable it (which rewrites hooks.php and syncs it on our network) to resolve it yourself.
HeadStand Posted November 21, 2018 Author Posted November 21, 2018 4 minutes ago, bfarber said: Yes, we've identified the issue (which affected more than just one or two clients, although it was still isolated) and have resolved it. If the client opens a ticket we can resynchronize their files to resolve the issue....or you can simply disable a plugin and re-enable it (which rewrites hooks.php and syncs it on our network) to resolve it yourself. For the record, disabling and re-enabling a plugin did not work for the original client I referenced. Just so you're aware.
bfarber Posted November 21, 2018 Posted November 21, 2018 52 minutes ago, HeadStand said: For the record, disabling and re-enabling a plugin did not work for the original client I referenced. Just so you're aware. Did they do that after we fixed the issue I just mentioned, however? 🙂
HeadStand Posted November 21, 2018 Author Posted November 21, 2018 1 minute ago, bfarber said: Did they do that after we fixed the issue I just mentioned, however? 🙂 The client I'm working with is not CIC. I don't have a ticket open for them.
bfarber Posted November 21, 2018 Posted November 21, 2018 Oh, then that would be a separate issue. Our network is load-balanced, and so if something is written to disk (i.e. the hooks.php file) it needs to be synced to each node. There was some temporary trouble with these syncs in some cases, which we've resolved. But, that would be specific to CiC and not a general issue.
HeadStand Posted November 21, 2018 Author Posted November 21, 2018 Just now, bfarber said: Oh, then that would be a separate issue. Our network is load-balanced, and so if something is written to disk (i.e. the hooks.php file) it needs to be synced to each node. There was some temporary trouble with these syncs in some cases, which we've resolved. But, that would be specific to CiC and not a general issue. Yes, you fixed it for another client, and I'm very grateful for that one! That was driving me nuts. I think these guys have some serious issues.... they probably SHOULD move to CIC, but it's not my call.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.