Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] is_granted twig helper is not registered #43560

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

Closed
BeyerJC opened this issue Oct 18, 2021 · 11 comments
Closed

[Security] is_granted twig helper is not registered #43560

BeyerJC opened this issue Oct 18, 2021 · 11 comments
Labels
Bug Help wanted Issues and PRs which are looking for volunteers to complete them. Security Status: Needs Review

Comments

@BeyerJC
Copy link

BeyerJC commented Oct 18, 2021

Symfony version(s) affected: 5.3.8

Description
After composer update and updating all recipes the "is_granted" twig function is not available anymore. When accessing a page i get

Did you forget to run "composer require symfony/security-core"? Unknown function "is_granted" in "_Base/_navigation.html.twig". (500 Internal Server Error)

I have "symfony/security-bundle": "5.3.*" in my composer.json and all libs are installed in vendor/. When i debug the cache warmup, the config "templating_twig.php" does not trigger my breakpoint, other configs in the security-bundle\config do.

Login does work normally.

It worked as expected before the composer update and my application was already on 5.3.1.

How to reproduce
Not sure.

Possible Solution

Additional context

name     : symfony/security-bundle
descrip. : Provides a tight integration of the Security component into the Symfony full-stack framework
keywords :
versions : * v5.3.8
type     : symfony-bundle
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : https://symfony.com
source   : []
dist     : [zip] https://*****/symfony/security-bundle/v5.3.8/symfony-security-bundle-v5.3.8.zip b755ed5d11685ba9aaa27b060250e5a57371f37f
path     : C:\Development\***\vendor\symfony\security-bundle
names    : symfony/security-bundle
 
@xabbuh
Copy link
Member

xabbuh commented Oct 18, 2021

Can you please show the output of composer show?

@BeyerJC
Copy link
Author

BeyerJC commented Oct 18, 2021

@xabbuh

bw/active-menu-item-bundle           1.5.0     The active menu item highlighting of simple HTML menu in Symfony applications
composer/package-versions-deprecated 1.11.99.4 Composer plugin that provides efficient querying for installed package versions (no runtime IO)
composer/semver                      3.2.5     Semver library that offers utilities, version constraint parsing and validation.
composer/xdebug-handler              2.0.2     Restarts a process without Xdebug.
doctrine/annotations                 1.13.2    Docblock Annotations Parser
doctrine/cache                       1.12.1    PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/collections                 1.6.8     PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                      2.13.3    PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, persistence interfaces, proxies, event system and much more.
doctrine/data-fixtures               1.5.1     Data Fixtures for all Doctrine Object Managers
doctrine/dbal                        2.13.4    Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/deprecations                v0.5.3    A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.
doctrine/doctrine-bundle             2.3.2     Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle  2.2.2     Symfony DoctrineMigrationsBundle
doctrine/event-manager               1.1.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                   1.4.4     PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator                1.4.0     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       1.2.1     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                  2.3.4     PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.
doctrine/orm                         2.7.5     Object-Relational-Mapper for PHP
doctrine/persistence                 1.3.8     The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/reflection                  1.2.2     The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functionality on top of the reflection functionality that comes with PHP. It allows you to get the reflection information about classes, methods and properties statically.
doctrine/sql-formatter               1.1.1     a PHP SQL highlighting library
eightpoints/guzzle-bundle            v8.2.0    Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony 2/3/4. Comes with easy and powerful configuration options and optional plugins.
elao/enum                            v1.16.0   Enumerations for PHP and frameworks integrations
fakerphp/faker                       v1.16.0   Faker is a PHP library that generates fake data for you.
firebase/php-jwt                     v5.4.0    A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
friendsofphp/php-cs-fixer            v3.2.1    A tool to automatically fix PHP code style
friendsofphp/proxy-manager-lts       v1.0.5    Adding support for a wider range of PHP versions to ocramius/proxy-manager
guzzlehttp/guzzle                    7.3.0     Guzzle is a PHP HTTP client library
guzzlehttp/promises                  1.5.0     Guzzle promises library
guzzlehttp/psr7                      2.1.0     PSR-7 message implementation that also provides common utility methods
hautelook/alice-bundle               2.9.0     Symfony bundle to manage fixtures with Alice and Faker.
knplabs/knp-components               v3.1.0    Knplabs component library
knplabs/knp-paginator-bundle         v5.7.0    Paginator bundle for Symfony to automate pagination and simplify sorting and other features
laminas/laminas-code                 4.4.3     Extensions to the PHP Reflection API, static code scanning, and code generation
league/oauth2-client                 2.6.0     OAuth 2.0 Client Library
monolog/monolog                      2.3.5     Sends your logs to files, sockets, inboxes, databases and various web services
myclabs/deep-copy                    1.10.2    Create deep copies (clones) of your objects
nelmio/alice                         v3.9.0    Expressive fixtures generator
nikic/php-parser                     v4.13.0   A PHP parser written in PHP
paragonie/random_compat              v9.99.100 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest                     2.0.3     Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                      3.1.0     Library for handling version information and constraints
php-cs-fixer/diff                    v2.0.2    sebastian/diff v3 backport support for PHP 5.6+
php-imap/php-imap                    4.1.99    Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
phpdocumentor/reflection-common      2.2.0     Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock    5.2.2     With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
phpdocumentor/type-resolver          1.5.1     A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/prophecy                     1.14.0    Highly opinionated mocking framework for PHP 5.3+
phpstan/extension-installer          1.1.0     Composer plugin for automatic installation of PHPStan extensions
phpstan/phpstan                      0.12.99   PHPStan - PHP Static Analysis Tool
phpstan/phpstan-doctrine             0.12.44   Doctrine extensions for PHPStan
phpstan/phpstan-phpunit              0.12.22   PHPUnit extensions and rules for PHPStan
phpstan/phpstan-symfony              0.12.44   Symfony Framework extensions and rules for PHPStan
phpunit/php-code-coverage            9.2.7     Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator            3.0.5     FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                  3.1.1     Invoke callables with a timeout
phpunit/php-text-template            2.0.4     Simple template engine.
phpunit/php-timer                    5.0.3     Utility class for timing
phpunit/phpunit                      9.5.10    The PHP Unit Testing framework.
plusnet/api-client                   1.2.1     Plusnet Api Client Bundle
plusnet/imap                         1.0.1     Plusnet Imap Bundle
plusnet/keycloak                     1.7.0     Plusnet Keycloak Authentication Bundle
psr/cache                            1.0.1     Common interface for caching libraries
psr/container                        1.1.1     Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                 1.0.0     Standard interfaces for event handling.
psr/http-client                      1.0.1     Common interface for HTTP clients
psr/http-factory                     1.0.1     Common interfaces for PSR-7 HTTP message factories
psr/http-message                     1.0.1     Common interface for HTTP messages
psr/log                              1.1.4     Common interface for logging libraries
ralouphie/getallheaders              3.0.3     A polyfill for getallheaders.
sebastian/cli-parser                 1.0.1     Library for parsing CLI options
sebastian/code-unit                  1.0.8     Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup   2.0.3     Looks up which function or method a line of code belongs to
sebastian/comparator                 4.0.6     Provides the functionality to compare PHP values for equality
sebastian/complexity                 2.0.2     Library for calculating the complexity of PHP code units
sebastian/diff                       4.0.4     Diff implementation
sebastian/environment                5.1.3     Provides functionality to handle HHVM/PHP environments
sebastian/exporter                   4.0.3     Provides the functionality to export PHP variables for visualization
sebastian/global-state               5.0.3     Snapshotting of global state
sebastian/lines-of-code              1.0.3     Library for counting the lines of code in PHP source code
sebastian/object-enumerator          4.0.4     Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector           2.0.4     Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context          4.0.4     Provides functionality to recursively process PHP variables
sebastian/resource-operations        3.0.3     Provides a list of PHP built-in functions that operate on resources
sebastian/type                       2.3.4     Collection of value objects that represent the types of the PHP type system
sebastian/version                    3.0.2     Library that helps with managing the version number of Git-hosted PHP projects
sensio/framework-extra-bundle        v5.6.1    This bundle provides a way to configure your controllers with annotations
symfony/amqp-messenger               v5.3.7    Symfony AMQP extension Messenger Bridge
symfony/asset                        v5.3.4    Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files
symfony/browser-kit                  v5.3.4    Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically
symfony/cache                        v5.3.8    Provides an extended PSR-6, PSR-16 (and tags) implementation
symfony/cache-contracts              v2.4.0    Generic abstractions related to caching
symfony/config                       v5.3.4    Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/console                      v5.3.7    Eases the creation of beautiful and testable command line interfaces
symfony/css-selector                 v5.3.4    Converts CSS selectors to XPath expressions
symfony/debug-bundle                 v5.3.4    Provides a tight integration of the Symfony Debug component into the Symfony full-stack framework
symfony/dependency-injection         v5.3.8    Allows you to standardize and centralize the way objects are constructed in your application
symfony/deprecation-contracts        v2.4.0    A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge              v5.1.11   Provides integration for Doctrine with various Symfony components
symfony/doctrine-messenger           v5.3.8    Symfony Doctrine Messenger Bridge
symfony/dom-crawler                  v5.3.7    Eases DOM navigation for HTML and XML documents
symfony/dotenv                       v5.3.8    Registers environment variables from a .env file
symfony/error-handler                v5.3.7    Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher             v5.3.7    Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts   v2.4.0    Generic abstractions related to dispatching event
symfony/expression-language          v5.3.7    Provides an engine that can compile and evaluate expressions
symfony/filesystem                   v5.3.4    Provides basic utilities for the filesystem
symfony/finder                       v5.3.7    Finds files and directories via an intuitive fluent interface
symfony/flex                         v1.17.1   Composer plugin for Symfony
symfony/form                         v5.3.8    Allows to easily create, process and reuse HTML forms
symfony/framework-bundle             v5.3.8    Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/http-client                  v5.3.8    Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/http-client-contracts        v2.4.0    Generic abstractions related to HTTP clients
symfony/http-foundation              v5.3.7    Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                  v5.3.9    Provides a structured process for converting a Request into a Response
symfony/lock                         v5.3.4    Creates and manages locks, a mechanism to provide exclusive access to a shared resource
symfony/messenger                    v5.3.9    Helps applications send and receive messages to/from other applications or via message queues
symfony/mime                         v5.3.8    Allows manipulating MIME messages
symfony/monolog-bridge               v5.3.7    Provides integration for Monolog with various Symfony components
symfony/monolog-bundle               v3.7.0    Symfony MonologBundle
symfony/options-resolver             v5.3.7    Provides an improved replacement for the array_replace PHP function
symfony/password-hasher              v5.3.8    Provides password hashing utilities
symfony/phpunit-bridge               v5.3.8    Provides utilities for PHPUnit, especially user deprecation notices management
symfony/polyfill-ctype               v1.23.0   Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme       v1.23.1   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu            v1.23.0   Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn            v1.23.0   Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer     v1.23.0   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring            v1.23.1   Symfony polyfill for the Mbstring extension
symfony/polyfill-php72               v1.23.0   Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73               v1.23.0   Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80               v1.23.1   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81               v1.23.0   Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/process                      v5.3.7    Executes commands in sub-processes
symfony/property-access              v5.3.8    Provides functions to read and write from/to an object or array using a simple string notation
symfony/property-info                v5.3.8    Extracts information about PHP class' properties using metadata of popular sources
symfony/proxy-manager-bridge         v5.3.4    Provides integration for ProxyManager with various Symfony components
symfony/redis-messenger              v5.3.8    Symfony Redis extension Messenger Bridge
symfony/routing                      v5.3.7    Maps an HTTP request to a set of configuration variables
symfony/runtime                      v5.3.4    Enables decoupling PHP applications from global state
symfony/security-bundle              v5.3.8    Provides a tight integration of the Security component into the Symfony full-stack framework
symfony/security-core                v5.3.8    Symfony Security Component - Core Library
symfony/security-csrf                v5.3.4    Symfony Security Component - CSRF Library
symfony/security-guard               v5.3.7    Symfony Security Component - Guard
symfony/security-http                v5.3.8    Symfony Security Component - HTTP Integration
symfony/serializer                   v5.3.8    Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.
symfony/serializer-pack              v1.0.4    A pack for the Symfony serializer
symfony/service-contracts            v2.4.0    Generic abstractions related to writing services
symfony/stopwatch                    v5.3.4    Provides a way to profile code
symfony/string                       v5.3.7    Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/templating                   v5.3.7    Provides all the tools needed to build any kind of template system
symfony/translation                  v5.3.9    Provides tools to internationalize your application
symfony/translation-contracts        v2.4.0    Generic abstractions related to translation
symfony/twig-bridge                  v5.3.7    Provides integration for Twig with various Symfony components
symfony/twig-bundle                  v5.3.4    Provides a tight integration of Twig into the Symfony full-stack framework
symfony/validator                    v5.3.8    Provides tools to validate values
symfony/var-dumper                   v5.3.8    Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter                 v5.3.8    Allows exporting any serializable PHP data structure to plain PHP code
symfony/web-profiler-bundle          v5.3.8    Provides a development tool that gives detailed information about the execution of any request
symfony/webpack-encore-bundle        v1.12.0   Integration with your Symfony app & Webpack Encore!
symfony/yaml                         v5.3.6    Loads and dumps YAML files
theofidry/alice-data-fixtures        1.4.0     Nelmio alice extension to persist the loaded fixtures.
theseer/tokenizer                    1.2.1     A small library for converting tokenized PHP source code into XML and potentially other formats
twig/twig                            v3.3.3    Twig, the flexible, fast, and secure template language for PHP
webmozart/assert                     1.10.0    Assertions to validate method input/output with nice error messages.

@BeyerJC
Copy link
Author

BeyerJC commented Oct 19, 2021

    if ($container::willBeAvailable('symfony/twig-bridge', LogoutUrlExtension::class, ['symfony/security-bundle'])) {
            $loader->load('templating_twig.php');
        }

I just checked and this condition results to false, thats why the twig function is not registered. Twig-Bridge and Security-Bundle are installed and loaded.

Anything i can provide thats helps debugging this ?

name     : symfony/twig-bridge
descrip. : Provides integration for Twig with various Symfony components
keywords :
versions : * v5.3.7
type     : symfony-bridge
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : https://symfony.com
source   : []
dist     : [zip] https://###/repository/symfony/twig-bridge/v5.3.7/symfony-twig-bridge-v5.3.7.zip 503e12aded4d5cbda4f8d1f3824c6a108119822f
path     : C:\####\vendor\symfony\twig-bridge
names    : symfony/twig-bridge 

@xabbuh
Copy link
Member

xabbuh commented Oct 19, 2021

Can you please also share your composer.json file?

@BeyerJC
Copy link
Author

BeyerJC commented Oct 19, 2021

Maybe this can help:

image

@BeyerJC
Copy link
Author

BeyerJC commented Oct 19, 2021

Can you please also share your composer.json file?

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.4",
        "ext-curl": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "bw/active-menu-item-bundle": "^1.1",
        "composer/package-versions-deprecated": "1.11.99.4",
        "doctrine/annotations": "^1.0",
        "doctrine/common": "^2",
        "doctrine/doctrine-bundle": "^2",
        "doctrine/doctrine-migrations-bundle": "^2",
        "doctrine/orm": "^2",
        "eightpoints/guzzle-bundle": "^8.2.0",
        "elao/enum": "^1.14",
        "knplabs/knp-paginator-bundle": "^5.0",
        "phpdocumentor/reflection-docblock": "^5.2",
        "plusnet/api-client": "^1.1",
        "plusnet/imap": "^1.0",
        "plusnet/keycloak": "^1.5",
        "sensio/framework-extra-bundle": "^5.1",
        "symfony/console": "5.3.*",
        "symfony/dotenv": "5.3.*",
        "symfony/flex": "^1.0",
        "symfony/form": "5.3.*",
        "symfony/framework-bundle": "5.3.*",
        "symfony/http-client": "5.3.*",
        "symfony/lock": "5.3.*",
        "symfony/messenger": "5.3.*",
        "symfony/mime": "5.3.*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/process": "5.3.*",
        "symfony/property-access": "5.3.*",
        "symfony/property-info": "5.3.*",
        "symfony/proxy-manager-bridge": "5.3.*",
        "symfony/runtime": "5.3.*",
        "symfony/security-bundle": "5.3.*",
        "symfony/serializer": "5.3.*",
        "symfony/templating": "5.3.*",
        "symfony/translation": "5.3.*",
        "symfony/validator": "5.3.*",
        "symfony/webpack-encore-bundle": "^1.0",
        "symfony/yaml": "5.3.*"
    },
    "require-dev": {
        "friendsofphp/php-cs-fixer": "^3.0",
        "hautelook/alice-bundle": "^2.5",
        "phpstan/extension-installer": "^1.0",
        "phpstan/phpstan": "^0.12",
        "phpstan/phpstan-doctrine": "^0.12",
        "phpstan/phpstan-phpunit": "^0.12",
        "phpstan/phpstan-symfony": "^0.12",
        "phpunit/phpunit": "^9.5",
        "symfony/browser-kit": "5.3.*",
        "symfony/css-selector": "5.3.*",
        "symfony/debug-bundle": "5.3.*",
        "symfony/phpunit-bridge": "5.3.*",
        "symfony/stopwatch": "5.3.*",
        "symfony/web-profiler-bundle": "5.3.*"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://####/repository/repository/"
        },
        {
            "packagist.org": false
        }
    ],
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "id": "01C5K02ASYADC9XPYMNWX2GKAN",
            "allow-contrib": true
        }
    }
}

@xabbuh
Copy link
Member

xabbuh commented Oct 19, 2021

Does it change anything if you require the Twig bridge explicitly so that it is not installed as a transitive dependency?

@BeyerJC
Copy link
Author

BeyerJC commented Oct 19, 2021

Does it change anything if you require the Twig bridge explicitly so that it is not installed as a transitive dependency?

Yes ! Nothing was installed or updated but now its working !

./composer.json has been updated
Running composer update symfony/twig-bridge
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
phpstan/extension-installer: Extensions installed

Run composer recipes at any time to see the status of your Symfony recipes.

But is it correct to have it explicitly added ?

@noofaq
Copy link

noofaq commented Dec 30, 2021

I have just experienced exactly the same issue which was solved by explicitly adding symfony/twig-bridge into composer.json

The issue started when I have removed dependency of php-translation/symfony-bundle package. It worked correctly before.

veriflies@21ff75c4bdaf:/var/www/vhosts/veriflies$ php composer.phar update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 2 updates, 6 removals
  - Removing nyholm/nsa (1.3.0)
  - Removing php-translation/common (3.1.0)
  - Removing php-translation/extractor (2.0.3)
  - Removing php-translation/symfony-bundle (0.12.3)
  - Removing php-translation/symfony-storage (2.3.0)
  - Removing symfony/intl (v5.4.2)
  - Upgrading symfony/twig-bundle (v5.4.0 => v6.0.1)
  - Upgrading symfony/validator (v5.4.2 => v6.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 2 updates, 6 removals
  - Downloading symfony/validator (v6.0.2)
  - Downloading symfony/twig-bundle (v6.0.1)
  - Removing symfony/intl (v5.4.2)
  - Removing php-translation/symfony-storage (2.3.0)
  - Removing php-translation/symfony-bundle (0.12.3)
  - Removing php-translation/extractor (2.0.3)
  - Removing php-translation/common (3.1.0)
  - Removing nyholm/nsa (1.3.0)
  - Upgrading symfony/validator (v5.4.2 => v6.0.2): Extracting archive
  - Upgrading symfony/twig-bundle (v5.4.0 => v6.0.1): Extracting archive
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
126 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

What about running composer global require symfony/thanks && composer thanks now?
This will spread some 💖  by sending a ★  to the GitHub repositories of your fellow package maintainers.

Symfony operations: 6 recipes (4e2fa261ae5316748d8031b0bde2f61f)
  - Unconfiguring symfony/intl (>=v5.4.2): From auto-generated recipe
  - Unconfiguring php-translation/symfony-storage (>=2.3.0): From auto-generated recipe
  - Unconfiguring php-translation/symfony-bundle (>=0.10): From github.com/symfony/recipes-contrib:master
  - Unconfiguring php-translation/extractor (>=2.0.3): From auto-generated recipe
  - Unconfiguring php-translation/common (>=3.1.0): From auto-generated recipe
  - Unconfiguring nyholm/nsa (>=1.3.0): From auto-generated recipe
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]

composer.show result (before and after adding explicitly twig-bridge into composer.json file:

async-aws/core                          1.13.0                    Core package to integrate with AWS. This is a lig...
async-aws/ses                           1.4.1                     SES client, part of the AWS SDK provided by Async...
aws/aws-crt-php                         v1.0.2                    AWS Common Runtime for PHP
aws/aws-sdk-php                         3.208.7                   AWS SDK for PHP - Use Amazon Web Services in your...
behat/gherkin                           v4.9.0                    Gherkin DSL parser for PHP
behat/transliterator                    v1.3.0                    String transliterator
box/spout                               v3.3.0                    PHP Library to read and write spreadsheet files (...
brick/math                              0.9.3                     Arbitrary-precision arithmetic library
bynder/bynder-php-sdk                   1.0.9                     Bynder PHP Library
codeception/assert-throws               1.2.1                     Assert exception was thrown without stopping a test
codeception/codeception                 4.1.27                    BDD-style testing framework
codeception/lib-asserts                 2.0.0                     Assertion methods used by Codeception core and As...
codeception/lib-innerbrowser            2.0.1                     Parent library for all Codeception framework modu...
codeception/module-asserts              2.0.1                     Codeception module containing various assertions
codeception/module-db                   2.0.0                     DB module for Codeception
codeception/module-doctrine2            2.0.0                     Doctrine2 module for Codeception
codeception/module-symfony              2.1.1                     Codeception module for Symfony framework
codeception/module-webdriver            2.0.1                     WebDriver module for Codeception
codeception/phpunit-wrapper             9.0.6                     PHPUnit classes used by Codeception
codeception/specify                     2.0.0                     BDD code blocks for PHPUnit and Codeception
codeception/stub                        4.0.0                     Flexible Stub wrapper for PHPUnit's Mock Builder
codeception/verify                      2.2.0                     BDD assertion library for PHPUnit
composer/ca-bundle                      1.3.1                     Lets you find a path to the system CA bundle, and...
composer/composer                       2.2.2                     Composer helps you declare, manage and install de...
composer/metadata-minifier              1.0.0                     Small utility library that handles metadata minif...
composer/package-versions-deprecated    1.11.99.4                 Composer plugin that provides efficient querying ...
composer/pcre                           1.0.0                     PCRE wrapping library that offers type-safe preg_...
composer/semver                         3.2.6                     Semver library that offers utilities, version con...
composer/spdx-licenses                  1.5.6                     SPDX licenses list and validation library.
composer/xdebug-handler                 2.0.3                     Restarts a process without Xdebug.
doctrine/annotations                    1.13.2                    Docblock Annotations Parser
doctrine/cache                          2.1.1                     PHP Doctrine Cache library is a popular cache imp...
doctrine/collections                    1.6.8                     PHP Doctrine Collections library that adds additi...
doctrine/common                         3.2.1                     PHP Doctrine Common project is a library that pro...
doctrine/dbal                           2.13.6                    Powerful PHP database abstraction layer (DBAL) wi...
doctrine/deprecations                   v0.5.3                    A small layer on top of trigger_error(E_USER_DEPR...
doctrine/doctrine-bundle                2.5.3                     Symfony DoctrineBundle
doctrine/doctrine-migrations-bundle     3.2.1                     Symfony DoctrineMigrationsBundle
doctrine/event-manager                  1.1.1                     The Doctrine Event Manager is a simple PHP event ...
doctrine/inflector                      2.0.4                     PHP Doctrine Inflector is a small library that ca...
doctrine/instantiator                   1.4.0                     A small, lightweight utility to instantiate objec...
doctrine/lexer                          1.2.1                     PHP Doctrine Lexer parser library that can be use...
doctrine/migrations                     3.3.2                     PHP Doctrine Migrations project offer additional ...
doctrine/orm                            2.10.4                    Object-Relational-Mapper for PHP
doctrine/persistence                    2.2.3                     The Doctrine Persistence project is a set of shar...
doctrine/sql-formatter                  1.1.2                     a PHP SQL highlighting library
egulias/email-validator                 3.1.2                     A library for validating emails against several RFCs
enqueue/dbal                            0.10.15                   Message Queue Doctrine DBAL Transport
enqueue/dsn                             0.10.8                    Parse DSN
enqueue/enqueue                         0.10.15                   Message Queue Library
enqueue/enqueue-bundle                  0.10.15                   Message Queue Bundle
enqueue/job-queue                       0.10.15                   Job Queue
enqueue/null                            0.10.15                   Enqueue Null transport
firebase/php-jwt                        v5.5.1                    A simple library to encode and decode JSON Web To...
friendsofphp/proxy-manager-lts          v1.0.5                    Adding support for a wider range of PHP versions ...
gedmo/doctrine-extensions               v3.4.0                    Doctrine2 behavioral extensions
google/auth                             v1.18.0                   Google Auth Library for PHP
google/cloud-core                       v1.43.1                   Google Cloud PHP shared dependency, providing fun...
google/cloud-vision                     v1.5.2                    Cloud Vision Client for PHP
google/common-protos                    1.4.0                     Google API Common Protos for PHP
google/gax                              v1.10.0                   Google API Core for PHP
google/grpc-gcp                         v0.2.0                    gRPC GCP library for channel management
google/protobuf                         v3.19.1                   proto library for PHP
grpc/grpc                               1.42.0                    gRPC library for PHP
guzzlehttp/guzzle                       6.5.5                     Guzzle is a PHP HTTP client library
guzzlehttp/oauth-subscriber             0.3.0                     Guzzle OAuth 1.0 subscriber
guzzlehttp/promises                     1.5.1                     Guzzle promises library
guzzlehttp/psr7                         1.8.3                     PSR-7 message implementation that also provides c...
justinrainbow/json-schema               5.2.11                    A library to validate a json schema.
laminas/laminas-code                    4.5.1                     Extensions to the PHP Reflection API, static code...
mikey179/vfsstream                      v1.6.10                   Virtual file system to mock the real file system ...
monolog/monolog                         2.3.5                     Sends your logs to files, sockets, inboxes, datab...
mtdowling/jmespath.php                  2.6.1                     Declaratively specify how to extract elements fro...
mtdowling/supervisor-event              v1.0.0                    Wires callback functions to Supervisor events
myclabs/deep-copy                       1.10.2                    Create deep copies (clones) of your objects
nikic/php-parser                        v4.13.2                   A PHP parser written in PHP
oneup/uploader-bundle                   3.1.3                     This Symfony bundle provides a server implementat...
phar-io/manifest                        2.0.3                     Component for reading phar.io manifest informatio...
phar-io/version                         3.1.0                     Library for handling version information and cons...
php-webdriver/webdriver                 1.12.0                    A PHP client for Selenium WebDriver. Previously f...
phpdocumentor/reflection-common         2.2.0                     Common reflection classes used by phpdocumentor t...
phpdocumentor/reflection-docblock       5.3.0                     With this component, a library can provide suppor...
phpdocumentor/type-resolver             1.5.1                     A PSR-5 based resolver of Class names, Types and ...
phpspec/prophecy                        v1.15.0                   Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage               9.2.10                    Library that provides collection, processing, and...
phpunit/php-file-iterator               3.0.6                     FilterIterator implementation that filters files ...
phpunit/php-invoker                     3.1.1                     Invoke callables with a timeout
phpunit/php-text-template               2.0.4                     Simple template engine.
phpunit/php-timer                       5.0.3                     Utility class for timing
phpunit/phpunit                         9.5.11                    The PHP Unit Testing framework.
psr/cache                               2.0.0                     Common interface for caching libraries
psr/container                           1.1.2                     Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                    1.0.0                     Standard interfaces for event handling.
psr/http-message                        1.0.1                     Common interface for HTTP messages
psr/log                                 2.0.0                     Common interface for logging libraries
queue-interop/amqp-interop              0.8.2                     AMQP interop
queue-interop/queue-interop             0.8.1                     Promoting the interoperability of MQs objects. Ba...
ralouphie/getallheaders                 3.0.3                     A polyfill for getallheaders.
ramsey/collection                       1.2.2                     A PHP library for representing and manipulating c...
ramsey/uuid                             4.2.3                     A PHP library for generating and working with uni...
react/promise                           v2.8.0                    A lightweight implementation of CommonJS Promises...
rize/uri-template                       0.3.4                     PHP URI Template (RFC 6570) supports both expansi...
rollerworks/password-strength-bundle    v2.2.2                    Password-strength validator bundle for Symfony
rollerworks/password-strength-validator v1.7.2                    Password-strength validator for Symfony
sebastian/cli-parser                    1.0.1                     Library for parsing CLI options
sebastian/code-unit                     1.0.8                     Collection of value objects that represent the PH...
sebastian/code-unit-reverse-lookup      2.0.3                     Looks up which function or method a line of code ...
sebastian/comparator                    4.0.6                     Provides the functionality to compare PHP values ...
sebastian/complexity                    2.0.2                     Library for calculating the complexity of PHP cod...
sebastian/diff                          4.0.4                     Diff implementation
sebastian/environment                   5.1.3                     Provides functionality to handle HHVM/PHP environ...
sebastian/exporter                      4.0.4                     Provides the functionality to export PHP variable...
sebastian/global-state                  5.0.3                     Snapshotting of global state
sebastian/lines-of-code                 1.0.3                     Library for counting the lines of code in PHP sou...
sebastian/object-enumerator             4.0.4                     Traverses array structures and object graphs to e...
sebastian/object-reflector              2.0.4                     Allows reflection of object attributes, including...
sebastian/recursion-context             4.0.4                     Provides functionality to recursively process PHP...
sebastian/resource-operations           3.0.3                     Provides a list of PHP built-in functions that op...
sebastian/type                          2.3.4                     Collection of value objects that represent the ty...
sebastian/version                       3.0.2                     Library that helps with managing the version numb...
seld/jsonlint                           1.8.3                     JSON Linter
seld/phar-utils                         1.2.0                     PHAR file format utilities, for when PHP phars yo...
sensio/framework-extra-bundle           v6.2.4                    This bundle provides a way to configure your cont...
shapecode/hidden-entity-type-bundle     5.1.0                     Hidden field for Symfony entities
silqcode/assets-utilities-bundle        dev-veriflies-300 f8af3d7 AssetsUtilitiesBundle for wide usage (even outsid...
silqcode/generic-bundle                 dev-veriflies-300 74872ad GenericBundle which adds a lot of useful features...
snc/redis-bundle                        4.0.1                     A Redis bundle for Symfony
symfony/amazon-mailer                   v6.0.0                    Symfony Amazon Mailer Bridge
symfony/asset                           v5.4.0                    Manages URL generation and versioning of web asse...
symfony/browser-kit                     v6.0.1                    Simulates the behavior of a web browser, allowing...
symfony/cache                           v6.0.2                    Provides an extended PSR-6, PSR-16 (and tags) imp...
symfony/cache-contracts                 v2.5.0                    Generic abstractions related to caching
symfony/config                          v6.0.2                    Helps you find, load, combine, autofill and valid...
symfony/console                         v5.4.2                    Eases the creation of beautiful and testable comm...
symfony/css-selector                    v5.4.2                    Converts CSS selectors to XPath expressions
symfony/debug-bundle                    v6.0.2                    Provides a tight integration of the Symfony VarDu...
symfony/dependency-injection            v6.0.2                    Allows you to standardize and centralize the way ...
symfony/deprecation-contracts           v2.5.0                    A generic function and convention to trigger depr...
symfony/doctrine-bridge                 v6.0.2                    Provides integration for Doctrine with various Sy...
symfony/dom-crawler                     v6.0.2                    Eases DOM navigation for HTML and XML documents
symfony/dotenv                          v6.0.2                    Registers environment variables from a .env file
symfony/error-handler                   v6.0.2                    Provides tools to manage errors and ease debuggin...
symfony/event-dispatcher                v5.4.0                    Provides tools that allow your application compon...
symfony/event-dispatcher-contracts      v2.5.0                    Generic abstractions related to dispatching event
symfony/expression-language             v6.0.1                    Provides an engine that can compile and evaluate ...
symfony/filesystem                      v6.0.0                    Provides basic utilities for the filesystem
symfony/finder                          v5.4.2                    Finds files and directories via an intuitive flue...
symfony/flex                            v2.0.1                    Composer plugin for Symfony
symfony/form                            v6.0.2                    Allows to easily create, process and reuse HTML f...
symfony/framework-bundle                v5.4.2                    Provides a tight integration between Symfony comp...
symfony/http-client                     v6.0.2                    Provides powerful methods to fetch HTTP resources...
symfony/http-client-contracts           v3.0.0                    Generic abstractions related to HTTP clients
symfony/http-foundation                 v6.0.2                    Defines an object-oriented layer for the HTTP spe...
symfony/http-kernel                     v6.0.2                    Provides a structured process for converting a Re...
symfony/lock                            v6.0.2                    Creates and manages locks, a mechanism to provide...
symfony/mailer                          v6.0.2                    Helps sending emails
symfony/mime                            v5.4.2                    Allows manipulating MIME messages
symfony/monolog-bridge                  v6.0.1                    Provides integration for Monolog with various Sym...
symfony/monolog-bundle                  v3.7.1                    Symfony MonologBundle
symfony/options-resolver                v6.0.0                    Provides an improved replacement for the array_re...
symfony/password-hasher                 v6.0.2                    Provides password hashing utilities
symfony/phpunit-bridge                  v6.0.0                    Provides utilities for PHPUnit, especially user d...
symfony/polyfill-ctype                  v1.23.0                   Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme          v1.23.1                   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu               v1.23.0                   Symfony polyfill for intl's ICU-related data and ...
symfony/polyfill-intl-idn               v1.23.0                   Symfony polyfill for intl's idn_to_ascii and idn_...
symfony/polyfill-intl-normalizer        v1.23.0                   Symfony polyfill for intl's Normalizer class and ...
symfony/polyfill-mbstring               v1.23.1                   Symfony polyfill for the Mbstring extension
symfony/polyfill-php72                  v1.23.0                   Symfony polyfill backporting some PHP 7.2+ featur...
symfony/polyfill-php73                  v1.23.0                   Symfony polyfill backporting some PHP 7.3+ featur...
symfony/polyfill-php80                  v1.23.1                   Symfony polyfill backporting some PHP 8.0+ featur...
symfony/polyfill-php81                  v1.23.0                   Symfony polyfill backporting some PHP 8.1+ featur...
symfony/process                         v6.0.2                    Executes commands in sub-processes
symfony/property-access                 v6.0.2                    Provides functions to read and write from/to an o...
symfony/property-info                   v6.0.2                    Extracts information about PHP class' properties ...
symfony/routing                         v5.4.0                    Maps an HTTP request to a set of configuration va...
symfony/runtime                         v6.0.0                    Enables decoupling PHP applications from global s...
symfony/security-bundle                 v6.0.2                    Provides a tight integration of the Security comp...
symfony/security-core                   v6.0.2                    Symfony Security Component - Core Library
symfony/security-csrf                   v6.0.1                    Symfony Security Component - CSRF Library
symfony/security-http                   v6.0.2                    Symfony Security Component - HTTP Integration
symfony/serializer                      v6.0.2                    Handles serializing and deserializing data struct...
symfony/service-contracts               v2.5.0                    Generic abstractions related to writing services
symfony/stopwatch                       v6.0.0                    Provides a way to profile code
symfony/string                          v6.0.2                    Provides an object-oriented API to strings and de...
symfony/templating                      v5.4.0                    Provides all the tools needed to build any kind o...
symfony/translation                     v5.4.2                    Provides tools to internationalize your application
symfony/translation-contracts           v2.5.0                    Generic abstractions related to translation
symfony/twig-bridge                     v6.0.2                    Provides integration for Twig with various Symfon...
symfony/twig-bundle                     v6.0.1                    Provides a tight integration of Twig into the Sym...
symfony/validator                       v6.0.2                    Provides tools to validate values
symfony/var-dumper                      v6.0.2                    Provides mechanisms for walking through any arbit...
symfony/var-exporter                    v6.0.0                    Allows exporting any serializable PHP data struct...
symfony/web-profiler-bundle             v6.0.2                    Provides a development tool that gives detailed i...
symfony/yaml                            v5.4.2                    Loads and dumps YAML files
theseer/tokenizer                       1.2.1                     A small library for converting tokenized PHP sour...
twig/twig                               v3.3.4                    Twig, the flexible, fast, and secure template lan...
webmozart/assert                        1.10.0                    Assertions to validate method input/output with n...
wsdltophp/domhandler                    2.0.4                     Decorative design pattern to ease DOM handling
wsdltophp/packagebase                   5.0.1                     Contains the base classes to be used by classes g...
wsdltophp/packagegenerator              4.1.1                     Generate hierarchical PHP classes based on a WSDL
wsdltophp/phpgenerator                  4.1.0                     Generate php source file
wsdltophp/wsdlhandler                   1.0.4                     Decorative design pattern to ease WSDL handling
wsdltophp/wssecurity                    2.0.2                     Allows to easily add Ws Security header to a SOAP...

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jun 21, 2022

So, the issue here is that if ($container::willBeAvailable('symfony/twig-bridge',... returns false because twig-bundle is a dev dependency.

I think the fix should be to check in src/Symfony/Bridge/Twig/UndefinedCallableHandler.php if the missing $component is installed (using Composer API when available), and if it is, then suggest to require twig-bundle instead of $component.

Up for a PR anyone?

@nicolas-grekas nicolas-grekas added the Help wanted Issues and PRs which are looking for volunteers to complete them. label Jun 21, 2022
@xabbuh
Copy link
Member

xabbuh commented Aug 3, 2022

see #47171

nicolas-grekas added a commit that referenced this issue Aug 3, 2022
…equired component is already installed (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[TwigBridge] suggest to install the Twig bundle when the required component is already installed

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #43560
| License       | MIT
| Doc PR        |

Commits
-------

c203ef2 suggest to install the Twig bundle when the required component is already installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Help wanted Issues and PRs which are looking for volunteers to complete them. Security Status: Needs Review
Projects
None yet
Development

No branches or pull requests

6 participants