Skip to content
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

introduce INFO_DEPRECATION_LOG event #2409

Merged
merged 3 commits into from Jun 5, 2018
Merged

introduce INFO_DEPRECATION_LOG event #2409

merged 3 commits into from Jun 5, 2018

Conversation

splitbrain
Copy link
Collaborator

@splitbrain splitbrain commented Jun 1, 2018

This adds an event to dbg_deprecated(). This allows plugins to handle deprecation warnings. One example would be https://github.com/cosmocode/dokuwiki-plugin-sentry

One thing I don't like, but don't know how to avaoid is that this function used to abort super early when $conf['allowdebug'] wasn't set.

However for the sentry plugin you probably would want logs, but still do not show any debugging to end users (which allow debug would do).

So now the backtrace is always built, the event triggered and then everything is sent to dbglog() which may simply throw everything away.

Suggestions on how to improve this welcome.

This adds an event to dbg_deprecated(). This allows plugins to handle
deprecation warnings. One example would be @cosmocode/dokuwiki-plugin-sentry

One thing I don't like, but don't know how to avaoid is that this
function used to abort super early when $conf['allowdebug'] wasn't set.

However for the sentry plugin you probably would want logs, but still do
not show any debugging to end users (which allow debug would do).

So now the backtrace is always built, the event triggered and then
everything is sent to dbglog() which may simply throw everything away.

Suggestions on how to improve this welcome.
@splitbrain splitbrain requested a review from micgro42 June 1, 2018 09:55
Copy link
Collaborator

@micgro42 micgro42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could change the condition to
if($event->advise_before() && $conf['allowdebug']) {
That might make the intent a bit clearer.

As an alternative: is it possible to query whether any handlers are registered for an event? If that is possible one could make an early return check for $conf['allowdebug'] and no handlers registered for event

Nonetheless, this event should work fine as it is now 👍

Sometimes, preparing the data for an event is expensive and only needed
if the event is actually handled. This allows for a quick check before
actually preparing and triggering the event.
now the method is aborting early again unless the data is actually used
@splitbrain
Copy link
Collaborator Author

@micgro42 I added a mechanism to check if there are registered handlers. Can you have a look again?

@micgro42
Copy link
Collaborator

micgro42 commented Jun 1, 2018

Looks good (though I havn't had time to try it yet)

@splitbrain splitbrain merged commit 8458d4b into master Jun 5, 2018
@splitbrain splitbrain deleted the deprecationevent branch June 5, 2018 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants