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

Inline compat controller layer #2352

Merged
merged 1 commit into from
Dec 1, 2021
Merged

Inline compat controller layer #2352

merged 1 commit into from
Dec 1, 2021

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Dec 1, 2021

Fixes #2351

When running bin/console cache:clear -vvv, building the cache is failing hard with this error:

[
  "exception" => Symfony\Component\ErrorHandler\Error\FatalError^ {
    -error: [
      "type" => 64,
      "message" => "Declaration of FOS\RestBundle\Controller\PreSymfony6AbstractFOSRestController::getSubscribedServices() must be compatible with Symfony\Bundle\FrameworkBundle\Controller\AbstractController::getSubscribedServices(): array",
      "file" => "./vendor/friendsofsymfony/rest-bundle/Controller/PreSymfony6AbstractFOSRestController.php",
      "line" => 27
    ]
    #message: "Compile Error: Declaration of FOS\RestBundle\Controller\PreSymfony6AbstractFOSRestController::getSubscribedServices() must be compatible with Symfony\Bundle\FrameworkBundle\Controller\AbstractController::getSubscribedServices(): array"
    #code: 0
    #file: "./vendor/friendsofsymfony/rest-bundle/Controller/PreSymfony6AbstractFOSRestController.php"
    #line: 27
    trace: {
      ./vendor/friendsofsymfony/rest-bundle/Controller/PreSymfony6AbstractFOSRestController.php:27 { …}
      ./vendor/symfony/error-handler/DebugClassLoader.php:287 { …}
      ./vendor/symfony/framework-bundle/CacheWarmer/AnnotationsCacheWarmer.php:84 { …}
      ./vendor/symfony/framework-bundle/CacheWarmer/AnnotationsCacheWarmer.php:84 { …}
      ./vendor/symfony/framework-bundle/CacheWarmer/AnnotationsCacheWarmer.php:62 { …}
      ./vendor/symfony/framework-bundle/CacheWarmer/AbstractPhpFileCacheWarmer.php:51 { …}
      ./vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:99 { …}
      ./vendor/symfony/framework-bundle/Command/CacheClearCommand.php:141 { …}
      ./vendor/symfony/console/Command/Command.php:291 { …}
      ./vendor/symfony/console/Application.php:997 { …}
      ./vendor/symfony/framework-bundle/Console/Application.php:94 { …}
      ./vendor/symfony/console/Application.php:299 { …}
      ./vendor/symfony/framework-bundle/Console/Application.php:80 { …}
      ./vendor/symfony/console/Application.php:171 { …}
      ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
      ./vendor/autoload_runtime.php:29 { …}
      ./bin/console:11 {
        {main}^
        › 
        › require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
        › 
      }
      ./bin/console:0 { …}
    }
  }
]

The error is coming from the annotation cache warmer in the framework bundle, which is parsing this list of classes from this bundle:

  13 => "FOS\RestBundle\Controller\AbstractFOSRestController"
  14 => "FOS\RestBundle\Controller\Annotations\AbstractParam"
  15 => "FOS\RestBundle\Controller\Annotations\AbstractScalarParam"
  16 => "FOS\RestBundle\Controller\Annotations\Copy"
  17 => "FOS\RestBundle\Controller\Annotations\Delete"
  18 => "FOS\RestBundle\Controller\Annotations\FileParam"
  19 => "FOS\RestBundle\Controller\Annotations\Get"
  20 => "FOS\RestBundle\Controller\Annotations\Head"
  21 => "FOS\RestBundle\Controller\Annotations\Link"
  22 => "FOS\RestBundle\Controller\Annotations\Lock"
  23 => "FOS\RestBundle\Controller\Annotations\Mkcol"
  24 => "FOS\RestBundle\Controller\Annotations\Move"
  25 => "FOS\RestBundle\Controller\Annotations\Options"
  26 => "FOS\RestBundle\Controller\Annotations\ParamInterface"
  27 => "FOS\RestBundle\Controller\Annotations\Patch"
  28 => "FOS\RestBundle\Controller\Annotations\Post"
  29 => "FOS\RestBundle\Controller\Annotations\PropFind"
  30 => "FOS\RestBundle\Controller\Annotations\PropPatch"
  31 => "FOS\RestBundle\Controller\Annotations\Put"
  32 => "FOS\RestBundle\Controller\Annotations\QueryParam"
  33 => "FOS\RestBundle\Controller\Annotations\RequestParam"
  34 => "FOS\RestBundle\Controller\Annotations\Route"
  35 => "FOS\RestBundle\Controller\Annotations\Unlink"
  36 => "FOS\RestBundle\Controller\Annotations\Unlock"
  37 => "FOS\RestBundle\Controller\Annotations\View"
  38 => "FOS\RestBundle\Controller\ControllerTrait"
  39 => "FOS\RestBundle\Controller\PostSymfony6AbstractFOSRestController"
  40 => "FOS\RestBundle\Controller\PreSymfony6AbstractFOSRestController"
]

For some reason, both the compat classes are being included in the map. Inlining the compat classes into the AbstractFOSRestController.php file seems to get around the issue.

@goetas goetas merged commit 9a17f71 into FriendsOfSymfony:3.x Dec 1, 2021
@goetas
Copy link
Member

goetas commented Dec 1, 2021

thank you!

@mbabker mbabker deleted the inline-compat-controller branch December 1, 2021 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

missing return type for getSubscribedServices in PreSymfony6AbstractFOSRestController
2 participants