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

Make controller actions case-sensitive #8426

Closed
wants to merge 1 commit into from
Closed

Make controller actions case-sensitive #8426

wants to merge 1 commit into from

Conversation

Zeichen32
Copy link
Contributor

See issue #8422

@tsteur
Copy link
Member

tsteur commented Jul 27, 2015

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?

@Zeichen32
Copy link
Contributor Author

I am on holiday this week, but I will add some tests next week. So we can tests all core plugin events.

@mattab mattab modified the milestone: 2.15.0 Aug 12, 2015
@mattab mattab added the Needs Review PRs that need a code review label Aug 17, 2015
@diosmosis
Copy link
Member

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.

@Zeichen32
Copy link
Contributor Author

I have started to write the tests. But i still have problems to get a list of all plugin event. 😢

@diosmosis
Copy link
Member

I believe @tsteur's comment was about going through all plugins via Plugin\Manager::getLoadedPlugins() and calling getListHooksRegistered() to get the events plugins listen to, then making sure that, if they are Controller... events, that the controller action exists.

Does this help you?

@tsteur
Copy link
Member

tsteur commented Aug 25, 2015

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);
           }
     }
}

@Zeichen32
Copy link
Contributor Author

Ah okay, thanks for the hint. During the course of the day i will add the commit.

Author:    Jens Averkamp <j.averkamp@two-developers.com>
@Zeichen32
Copy link
Contributor Author

Ive add the test and squash the commits. 👍

@tsteur
Copy link
Member

tsteur commented Aug 28, 2015

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

@Zeichen32
Copy link
Contributor Author

Yes, I have tested it. For test purpose i had added some test events because currently Piwik does not listening on any Controller Event.

@tsteur
Copy link
Member

tsteur commented Aug 30, 2015

@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

@mattab
Copy link
Member

mattab commented Aug 31, 2015

Thanks for reminding me re: BC break. We'll target 3.0.0 then 👍

@mattab mattab modified the milestones: 3.0.0, 2.15.0 Aug 31, 2015
@mattab
Copy link
Member

mattab commented Sep 18, 2015

Hi @Zeichen32 - would you mind re-opening the PR against the 3.0.0 branch?

@Zeichen32
Copy link
Contributor Author

@mattab Done 👍

@mattab mattab modified the milestones: 3.0.0, 3.0.0-b1 Sep 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants