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
Make controller actions case-sensitive #8426
Conversation
Looks good to me. I reckon we should maybe add some tests after this merge see #8422 (comment) . It's possible we break someone's plugin (or our own plugins) with this change in case one had a typo etc. We'd have to mention it in the changelog. Don't think it needs to wait till Piwik 3.0, any other opinions? |
I am on holiday this week, but I will add some tests next week. So we can tests all core plugin events. |
Hi @Zeichen32 are you still planning to add a test? If you don't have time, let me know and I'll add it before merging. |
I have started to write the tests. But i still have problems to get a list of all plugin event. 😢 |
I believe @tsteur's comment was about going through all plugins via Does this help you? |
Exactly. I haven't tested it but something like this should roughly work: foreach (Plugin\Manager::getLoadedPlugins() as $plugin) {
$hooks = $plugin->getListHooksRegistered();
foreach ($hooks as $hook => $callback) {
if (0 === strpos($hook, 'Controller.')) {
// here you explode $hook to get controller module and action
list($controller, $module, $action) = explode('.', $hook);
// then you can assert the controller exists like this:
try {
$resolver = new ControllerResolver(StaticContainer::getContainer());
$controller = $resolver->getController($module, $action);
} catch (\Exception $e) {
$this->fail("$hook is listening to a controller method that does not exist");
}
$this->assertNotEmpty($controller);
}
}
} |
Ah okay, thanks for the hint. During the course of the day i will add the commit. |
Ive add the test and squash the commits. 👍 |
Looks good to merge. Have you tested whether it actually fails if there was an event listening to it? I think in Piwik itself there's none so far. I'm wondering if it's good to merge for 2.15 or 3.0. It may break other plugins if the event wasn't correctly spelled or if the URL doesn't match the case |
Yes, I have tested it. For test purpose i had added some test events because currently Piwik does not listening on any Controller Event. |
@mattab I reckon it's your call whether we should merge in 2.15 or 3.0 re possibly breaking URL's and maybe events |
Thanks for reminding me re: BC break. We'll target 3.0.0 then 👍 |
Hi @Zeichen32 - would you mind re-opening the PR against the |
@mattab Done 👍 |
See issue #8422