skip to Main Content

I upgraded my Contao website from 4.13.38 to 5.3.1. Everything was successful, Contao Manager is working okay, but the website is not functioning. The error is logged in var/logs and points to a non-existent service "contao.image.image_sizes":

Uncaught PHP Exception SymfonyComponentDependencyInjectionExceptionServiceNotFoundException: "You have requested a non-existent service "contao.image.image_sizes". Did you mean one of these: "contao.image.imagine", "contao.image.imagine_svg", "contao.image.resizer", "contao.image.sizes"?" at Container.php line 263

{
"exception": 
"[object] (SymfonyComponentDependencyInjectionExceptionServiceNotFoundException(code: 0): You have requested a non-existent service "contao.image.image_sizes". Did you mean one of these: "contao.image.imagine", "contao.image.imagine_svg", "contao.image.resizer", "contao.image.sizes"? at /opt/testportal/vendor/symfony/dependency-injection/Container.php:263)"
}
{
"request_uri": "https://testportal/contao/login",
"request_method": "GET"
}

Both FE and BE are not working.

What could be the problem here? I searched for solution in Internet, but although there were similar questions, I didn’t find real solution.

Beside contao-core bundles, there are rocksolidthemes (madeyourday) plugins installed and upgraded.

2

Answers


  1. Chosen as BEST ANSWER

    Solution

    The problem was caused by theme I used. The theme files should be also actualized after the upgrade, but since the BackEnd is not working, it's not possible to do that by theme import, and files should be replaced manually over FTP.

    In my case, it was Oneo theme and files that were using the wrong service are:

    rsce_oneo_centered_wrapper_start_config.php
    rsce_oneo_feature_box_config.php
    rsce_oneo_tab_nav_config.php
    rsce_oneo_timeline_config.php
    

    In each of these of files there is line

    'options' => ContaoSystem::getContainer()->get('contao.image.image_sizes')->getAllOptions(),
    

    and in actualized version (for Contao 5.0 - 5.3) the line is changed to:

    'options' => ContaoSystem::getContainer()->get('contao.image.sizes')->getAllOptions(),
    

    Alternative solution:

    In folder config there should be added file services.yaml with following code:

    services:
        contao.image.image_sizes:
            class: ContaoCoreBundleImageImageSizes
            public: true
            arguments:
              - '@database_connection'
              - '@event_dispatcher'
              - '@contao.translation.translator
    

    This is the same configuration as it is for service contao.image.sizes in core-bundle, but for some reason the system is searching for contao.image.image_sizes. Since that service is not exists, we copied the definition under the name of missing service.

    Somewhere I found this code, and there is probably why the system is searching for contao.image.image_sizes

    public static function getImageSizes()
        {
            @trigger_error('Using System::getImageSizes() has been deprecated and will no longer work in Contao 5.0. Use the contao.image.image_sizes service instead.', E_USER_DEPRECATED);
            return static::getContainer()->get('contao.image.image_sizes')->getAllOptions();
        }
    

  2. When updating Contao you will also always need to update the theme, according to the theme vendor’s instructions – especially when updating to new minor or major versions. In your case you did not update the RockSolid Custom Elements config files of the Oneo theme for example for the new Contao version which resulted in this error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search