Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Updating 2.5.3 to 2.6.2 breaks url() view helper, "No RouteStackInterface instance provided" #51

Closed
BenjaminNolan opened this issue Feb 21, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@BenjaminNolan
Copy link

About an hour or so ago I did a composer update which included an automatic update for this module from 2.5.3 to 2.6.2. After this update was installed, the url() view helper fatally stopped working as null === $this->router, which caused it to throw Exception\RuntimeException('No RouteStackInterface instance provided') from Zend\View\Helper\Url at line 54.

Unfortunately, that's all I've got at the moment as I haven't had a chance to dig deeper into what's actually causing the problem, but I'm hoping someone will have an idea from this. That said, I am specifically requiring "zendframework/zendframework": "2.5.*" in composer.json, so it could be a version incompatibility? I've added a require line to force "zendframework/zend-view": "2.5.*" which has resolved the issue for me at least for the time being.

@BenjaminNolan BenjaminNolan changed the title Updating 2.5.3 to 2.6.2 breaks url() view helper, "No RouteStackInterface provided exception" Updating 2.5.3 to 2.6.2 breaks url() view helper, "No RouteStackInterface instance provided" Feb 21, 2016
@stefanorg
Copy link

i can confirm, it also happen to me from 2.5.3 to 2.6.2.

@weierophinney weierophinney added this to the 2.6.3 milestone Feb 22, 2016
@weierophinney weierophinney self-assigned this Feb 22, 2016
@weierophinney
Copy link
Member

I've isolated the issue.

In versions prior to 2.6, we define $invokableClasses. To make these forwards compatible with version 3, we split all $invokableClasses entries into $aliases and $factories entries (with the latter using the new Zend\ServiceManager\Factory\InvokableFactory). The factory keys are fully qualified class names, while the aliases are the "short" names.

What this means is that url is an alias to Zend\View\Helper\Url within the helper plugin manager. However, in zend-mvc, we define an override factory that ensures that the route match and router are injected. The problem? It uses the key "url", and, since an alias also exists with that same name, the alias is resolved. As such, the override factory is never invoked.

I'm going to open a new issue on zend-mvc to address this.

@weierophinney
Copy link
Member

I have a patch ready at zendframework/zend-mvc#71.

Could one of those of you who are affected by the issue please test? You can do so as follows:

  1. Add my repo to your composer.json:
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/weierophinney/zend-mvc.git"
    }
],
  1. Add an override for the zend-mvc dependency to your composer.json:
"require": {
    "zendframework/zend-mvc": "dev-hotfix/71 as 2.6.2"
}
  1. Update your dependencies:
$ composer update zendframework/zend-mvc

You should see that composer installs from my repo at that point.

Then let me know if the patch works!

@ThaDafinser
Copy link
Contributor

Had the same issue.

Solving it without rewrite your own code would require to add the line below with comment
image

To avoid it in the meantime, it's possible to create a own factory with the code from here
image

@ThaDafinser
Copy link
Contributor

@TwoWholeWorms @stefanorg how you guys solved it?

Also with a similar "hack" like i posted above? Or something elese?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants