symfony-cmf / menu-bundle

Extends the KnpMenuBundle to work with PHPCR ODM
https://cmf.symfony.com
32 stars 48 forks source link

deprecated use of "request" attribute of the "knp_menu.voter" tag #303

Closed ob1201 closed 6 years ago

ob1201 commented 6 years ago

On Symfony4,

composer show -l 'symfony/*'
    symfony/asset                v4.0.4             v4.0.4             Symfony Asset Component
    symfony/browser-kit          v4.0.4             v4.0.4             Symfony BrowserKit Com...
    symfony/cache                v4.0.4             v4.0.4             Symfony Cache componen...
    symfony/class-loader         v3.4.4             v3.4.4             Symfony ClassLoader Co...
    symfony/config               v4.0.4             v4.0.4             Symfony Config Component
    symfony/console              v4.0.4             v4.0.4             Symfony Console Component
    symfony/css-selector         v4.0.4             v4.0.4             Symfony CssSelector Co...
    symfony/debug                v4.0.4             v4.0.4             Symfony Debug Component
    symfony/debug-bundle         v4.0.4             v4.0.4             Symfony DebugBundle
    symfony/debug-pack           v1.0.4             v1.0.4             A debug pack for Symfo...
    symfony/dependency-injection v4.0.4             v4.0.4             Symfony DependencyInje...
    symfony/doctrine-bridge      v4.0.4             v4.0.4             Symfony Doctrine Bridge
    symfony/dom-crawler          v4.0.4             v4.0.4             Symfony DomCrawler Com...
    symfony/dotenv               v4.0.4             v4.0.4             Registers environment ...
    symfony/event-dispatcher     v4.0.4             v4.0.4             Symfony EventDispatche...
    symfony/expression-language  v4.0.4             v4.0.4             Symfony ExpressionLang...
    symfony/filesystem           v4.0.4             v4.0.4             Symfony Filesystem Com...
    symfony/finder               v4.0.4             v4.0.4             Symfony Finder Component
    symfony/flex                 v1.0.70            v1.0.70           
    symfony/form                 v4.0.4             v4.0.4             Symfony Form Component
    symfony/framework-bundle     v4.0.4             v4.0.4             Symfony FrameworkBundle
    symfony/http-foundation      v4.0.4             v4.0.4             Symfony HttpFoundation...
    symfony/http-kernel          v4.0.4             v4.0.4             Symfony HttpKernel Com...
    symfony/inflector            v4.0.4             v4.0.4             Symfony Inflector Comp...
    symfony/intl                 v4.0.4             v4.0.4             A PHP replacement laye...
    symfony/lts                  dev-master 396c5fc dev-master 396c5fc Enforces Long Term Sup...
    symfony/maker-bundle         v1.1.1             v1.1.1             Symfony Maker helps yo...
    symfony/monolog-bridge       v4.0.4             v4.0.4             Symfony Monolog Bridge
    symfony/monolog-bundle       v3.1.2             v3.1.2             Symfony MonologBundle
    symfony/options-resolver     v4.0.4             v4.0.4             Symfony OptionsResolve...
    symfony/orm-pack             v1.0.5             v1.0.5             A pack for the Doctrin...
    symfony/phpunit-bridge       v4.0.4             v4.0.4             Symfony PHPUnit Bridge
    symfony/polyfill-intl-icu    v1.7.0             v1.7.0             Symfony polyfill for i...
    symfony/polyfill-mbstring    v1.7.0             v1.7.0             Symfony polyfill for t...
    symfony/polyfill-php72       v1.7.0             v1.7.0             Symfony polyfill backp...
    symfony/process              v4.0.4             v4.0.4             Symfony Process Component
    symfony/profiler-pack        v1.0.3             v1.0.3             A pack for the Symfony...
    symfony/property-access      v4.0.4             v4.0.4             Symfony PropertyAccess...
    symfony/property-info        v4.0.4             v4.0.4             Symfony Property Info ...
    symfony/routing              v4.0.4             v4.0.4             Symfony Routing Component
    symfony/security             v4.0.4             v4.0.4             Symfony Security Compo...
    symfony/security-acl         v3.0.1             v3.0.1             Symfony Security Compo...
    symfony/security-bundle      v4.0.4             v4.0.4             Symfony SecurityBundle
    symfony/serializer           v4.0.4             v4.0.4             Symfony Serializer Com...
    symfony/serializer-pack      v1.0.1             v1.0.1             A pack for the Symfony...
    symfony/stopwatch            v4.0.4             v4.0.4             Symfony Stopwatch Comp...
    symfony/swiftmailer-bundle   v3.2.0             v3.2.0             Symfony SwiftmailerBundle
    symfony/templating           v4.0.4             v4.0.4             Symfony Templating Com...
    symfony/translation          v4.0.4             v4.0.4             Symfony Translation Co...
    symfony/twig-bridge          v4.0.4             v4.0.4             Symfony Twig Bridge
    symfony/twig-bundle          v4.0.4             v4.0.4             Symfony TwigBundle
    symfony/validator            v4.0.4             v4.0.4             Symfony Validator Comp...
    symfony/var-dumper           v4.0.4             v4.0.4             Symfony mechanism for ...
    symfony/web-link             v4.0.4             v4.0.4             Symfony WebLink Component
    symfony/web-profiler-bundle  v4.0.4             v4.0.4             Symfony WebProfilerBundle
    symfony/webpack-encore-pack  v1.0.2             v1.0.2             A pack for Symfony Encore
    symfony/yaml                 v4.0.4             v4.0.4             Symfony Yaml Component

with

composer show -l '*cmf*'
    symfony-cmf/core-bundle          dev-master dfba976 dev-master dfba976 Symfony CMF Core B...
    symfony-cmf/menu-bundle          dev-master 5c6bd22 dev-master 5c6bd22 Symfony CMF Menu B...
    symfony-cmf/resource             1.0.0              1.0.0              Bundle which facil...
    symfony-cmf/resource-bundle      dev-master 331fb91 dev-master 331fb91 Bundle which facil...
    symfony-cmf/resource-rest-bundle dev-master 8f2ccc6 dev-master 8f2ccc6 Bundle which provi...
    symfony-cmf/routing              dev-master e1bc515 dev-master e1bc515 Extends the Symfon...
    symfony-cmf/routing-bundle       dev-master bf20a1f dev-master bf20a1f Symfony RoutingBundle
    symfony-cmf/tree-browser-bundle  dev-master 14ddf7d dev-master 14ddf7d Symfony CMF Tree B...

I've also installed

knplabs/knp-menu                         dev-master e11c6cd An object oriented menu li...
knplabs/knp-menu-bundle                  dev-master 6bea43e This bundle provides an in...

in profiler I see

Using the "request" attribute of the "knp_menu.voter" tag is deprecated since version 2.2. Inject the RequestStack in the voter instead.

{▼

  /opt/evals/symfony4/vendor/knplabs/knp-menu-bundle/src/DependencyInjection/Compiler/AddVotersPass.php:43 {▶}
  /opt/evals/symfony4/vendor/symfony/dependency-injection/Compiler/Compiler.php:95 {▶}
}

relevant reference here, I think

Add support for autoconfiguring menu voters #353 https://github.com/KnpLabs/KnpMenuBundle/pull/353

checking

bin/console debug:container --tag knp_menu.voter --show-private

    Symfony Container Public and Private Services Tagged with "knp_menu.voter" Tag

    ---------------------------------------- --------- ----------------------------------------------------
     Service ID                               request   Class name                              
    ---------------------------------------- --------- ----------------------------------------------------

     cmf_menu.current_item_voter.uri_prefix   1         Symfony\Cmf\Bundle\MenuBundle\Voter\UriPrefixVoter
     knp_menu.voter.router                              Knp\Menu\Matcher\Voter\RouteVoter      
     sonata.admin.menu.matcher.voter.active             Sonata\AdminBundle\Menu\Matcher\Voter\ActiveVoter
     sonata.admin.menu.matcher.voter.admin              Sonata\AdminBundle\Menu\Matcher\Voter\AdminVoter

    ---------------------------------------- --------- ----------------------------------------------------

in #support, was informed

the issue is the CMF voter here, which still use the deprecated way to access the request. Please report it to them

add'l comment in #symfony-cmf was

Q: Not clear what the 'deprecated way' is ...
A: Fetching `request` from container instead of injecting `request_stack`
Xymanek commented 6 years ago

Fix of same problem in another library: https://github.com/sonata-project/SonataAdminBundle/pull/4869

ElectricMaxxx commented 6 years ago

Awesome prepared issue description. The fix is just in front of us. The issue is that clear, you could open a PR on your own, or?

ob1201 commented 6 years ago

you could open a PR on your own

open, yes. start blindly copying, yes. beyond that ... unclear how wise it is to have me fixing this I've never used any of this yet. still at 1st install, trying to get deprecations resolved In any case, there^ you go.

SalvatorePollaci commented 6 years ago

Guys when will this fix be released?

dbu commented 6 years ago

thanks @ob1201