Skip to content

Hook rewrite return value#134

Merged
barryo merged 4 commits intoopensolutions:masterfrom
mfechner:hook_rewrite_return_value
Apr 2, 2016
Merged

Hook rewrite return value#134
barryo merged 4 commits intoopensolutions:masterfrom
mfechner:hook_rewrite_return_value

Conversation

@mfechner
Copy link
Copy Markdown
Contributor

I required the functionality to implement checks in plugins.
These checks must be able to forbid core to write values into the database.
As this logic is part of the plugin the hook system must be able to handle return values.

With these modifications the called hooks can return a false value and therefor are able to inform core to not execute the triggered action, but display an error message.

Would be nice if this could be merged into the repository.

@barryo
Copy link
Copy Markdown
Member

barryo commented Mar 28, 2015

Hi!

One key requirement of pulling in changes is that it won't affect existing behaviour. From a quick glance, it looks like this will break all existing plugins as it goes from assuming no return to requiring a positive return 😢

I'll have a deeper look when I have some time an tidy it up.

@barryo
Copy link
Copy Markdown
Member

barryo commented Mar 28, 2015

Hi @idefix6 - can you state your agreement to the Contributor License Agreement v1.0 in a comment here please.

@barryo
Copy link
Copy Markdown
Member

barryo commented Apr 1, 2015

Hi @idefix6 - can you state your agreement (or objections) to the Contributor License Agreement v1.0 in a comment here please.

@PhrozenByte
Copy link
Copy Markdown
Contributor

Just my humble 2 cents: This CLA states nothing. All terms are already part of the GPL. You can neither modify nor even use ViMbAdmin without accepting those terms. Moreover, this CLA actually restricts your (Open Solutions) posssibility to license ViMbAdmin under a later version of the GPL in the future: The current code is "GPLv3 or any later version", the CLA states "GPLv3" only. Don't use CLAs. Many developers will be put off. http://ebb.org/bkuhn/blog/2014/06/09/do-not-need-cla.html

@mfechner
Copy link
Copy Markdown
Contributor Author

mfechner commented Apr 1, 2015

Am 28.03.2015 um 13:54 schrieb barryo:

Hi @idefix6 https://github.com/idefix6 - can you state your agreement
to the Contributor License Agreement
https://github.com/opensolutions/ViMbAdmin/wiki/Contributor-License-Agreement
v1.0 in a comment here please.

I agree.

Gruß
Matthias

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

@mfechner
Copy link
Copy Markdown
Contributor Author

mfechner commented Apr 1, 2015

Hi Barry,

Am 28.03.2015 um 13:45 schrieb barryo:

One key requirement of pulling in changes is that it won't affect
existing behaviour. From a quick glance, it looks like this will break
all existing plugins as it goes from assuming no return to requiring a
positive return 😢

I'll have a deeper look when I have some time an tidy it up.

do you have plugins that are using hooks?
I have a standard config running and found no problems yet (but maybe I
do not use all plugins).

But you are right, the plugins must be modified to return a true in
there hooks.
If a hook is not existing, commit:
mfechner@eb6a46e
ensures that always true is returned, but that matched only for not
existing hooks.

Gruß
Matthias

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the universe trying to
produce bigger and better idiots. So far, the universe is winning." --
Rich Cook

@mfechner
Copy link
Copy Markdown
Contributor Author

I just had a look into the changes again and it only has an effect on plugins that will implement an alias PreRemove hook.
I checked all plugins and no one is implementing such a hook, so the modification will not break anything. Maybe we should add to the documentation that a Pre- hook must always return a true value if it was successfully executed to enable the Pre- checks.

Maybe the steps we could do are:

  1. Update documentation, pre hooks must always return a true if they were executed successfully
  2. Pull my request, that will only effect the Aliases PreDelete hook
  3. Update all PreDelete implementations to return a true value
  4. Modify all other controller to check the return value

I think this has the lowest impact and would reduce the risk to really break anything by accident.
What do you think?

@mfechner mfechner force-pushed the hook_rewrite_return_value branch 2 times, most recently from bdc4478 to 4c938c7 Compare May 31, 2015 13:05
@mfechner mfechner force-pushed the hook_rewrite_return_value branch from 4c938c7 to dd929df Compare April 2, 2016 11:42
mfechner added 4 commits April 2, 2016 14:18
… it return a false.

This is required to do additional checks in plugins that can stop the main application to finish the action.
…lugins give green light to continue with the deletion.
…to return error message to user why a alias could not be deactivated.
@mfechner mfechner force-pushed the hook_rewrite_return_value branch from dd929df to b65ac65 Compare April 2, 2016 12:19
@mfechner
Copy link
Copy Markdown
Contributor Author

mfechner commented Apr 2, 2016

Dear Barry,

any chance to get the modification I did 2 years ago part of the master branch?
This first modification should not have an impact to any existing module.

@barryo barryo merged commit b65ac65 into opensolutions:master Apr 2, 2016
barryo added a commit that referenced this pull request Apr 2, 2016
@barryo
Copy link
Copy Markdown
Member

barryo commented Apr 2, 2016

@idefix6 - done with a little tidying up and better retention of existing logic.

@mfechner mfechner deleted the hook_rewrite_return_value branch April 2, 2016 13:35
@mfechner
Copy link
Copy Markdown
Contributor Author

mfechner commented Apr 2, 2016

@barryo sorry, your tidy up broke all my pending changes I would like to merge, the intension here was to get my modifications as clearly and savely as possible into master branch. I will rewrite all my pending branches to get it alligned with your tidy-up.

@barryo
Copy link
Copy Markdown
Member

barryo commented Apr 2, 2016

Sorry @idefix6 - I hope you can see what my intention was? Essentially: code works just as expected for everyone else.

@mfechner
Copy link
Copy Markdown
Contributor Author

mfechner commented Apr 2, 2016

Dear @barryo no problem, I cleaned up my modifications and send a new pull request to get a new hook available.

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.

3 participants