-
-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add warnings for undesired changes to plugin hook return values #4390
Comments
The plugin API should detect when plugins are not behaving properly with return variables required for chaining
The WARNINGS above are just an example. Since this plugin was the only plugin calling the hook, it will not generate a warning even though it is using bad form. |
So after updating, I noticed that the monitor plugin no longer showed the monitor tab. I disabled monitor and re-enabled and got your warnings. So syslog, monitor and weathermap need some love.
|
Okay. Let me dig in to these. |
Part of the functionality of the API was that a plugin can effectively cancel a hook by returning false. As such, I do not think we should be reporting these warnings except at a debug level (or maybe high at a push). It's been useful to have it log always here as we have had immediate feedback from @jdcoats (tanks for that!) but we should correct the logging level for release. |
@jdcoats, can you post the contents of this function |
In the case of the top_graph_refresh, an array is sent in, but an integer is sent back. So, the test case would be |
|
It's bad logic in the |
This allows $ret calls that were initially empty to not trigger an error. This was applicable for the graph refresh hook that, if the user has no default setting, will initialize as null.
Should be all set now. |
updated and warnings are gone, will continue on testing. |
Commit 63e1998 is still wrong. As I commented on there, there are scenario's where the changing of the return value type between array and string is expected and desired. Also, the part about |
Why has this been closed without addressing the above? |
Re-read my comment. We need to log a new issue. This one is closed for the reasons I stated above. |
You haven't stated any reason above, just that it's all set. I'm going to assume that the $result only kicks in if there are more than one listeners for a given hook? But if that's the case, that would be better as the outer IF statement since it's less complex and not as likely to be true unless you have a lot of plugins that all use the same hook. |
Yea, it was in the commit comment. Sorry about that. |
That's OK, just trying to make sure we are both following things correctly and not missing something. My understanding of the hooks logic there has changed each time I read it but I think I have it now. It will be curious to see who exactly does see the warning. |
Describe the bug
The Cacti plugin API is dependent on plugin authors returning certain structures to be used by other plugin authors. These structures should ALWAYS be returned. Otherwise errors can be thrown by plugins that assume that they are set.
In the event this happens, Cacti should make every effort to detect this and warn the user who can then either correct this issue, or report it to the plugin maintainer.
Expected behavior
Cacti should do a better job of detecting cases where plugin authors are not using good form when authoring plugins.
Screenshots
Below is an example of the new error that will be logged in the case of a chaining event when there is greater than one plugin using the hook function.
The text was updated successfully, but these errors were encountered: