Skip to content
Snippets Groups Projects

Resolve #3502882 "Bc classloader"

Open catch requested to merge issue/drupal-3502882:3502882-bc-classloader into 11.x
2 unresolved threads

Closes #3502882

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
24 $this->movedClasses = $this->parameterBag->get('core.moved_classes');
25 }
26 if ($this->parameterBag->has('container.modules')) {
27 foreach (array_keys($this->parameterBag->get('container.modules')) as $module) {
28 if ($this->parameterBag->has($module . '.moved_classes')) {
29 $this->movedClasses = $this->movedClasses + $this->parameterBag->get($module . '.moved_classes');
30 }
31 }
32 }
33 }
34
35 if (isset($this->movedClasses[$class])) {
36 $moved = $this->movedClasses[$class];
37 if (isset($moved['deprecation_version']) && isset($moved['removed_version'])) {
38 // @phpcs:ignore
39 @trigger_error(sprintf('Class %s is deprecated in %s and is removed from %s. See %s', $class, $moved['deprecation_version'], $moved['removed_version'], $moved['class']), E_USER_DEPRECATED);
  • catch added 1 commit

    added 1 commit

    • c3e6a9ef - Move parameter merging to the container, make deprecation message fit the standard.

    Compare with previous version

  • catch added 1 commit

    added 1 commit

    Compare with previous version

  • catch added 1 commit

    added 1 commit

    Compare with previous version

  • catch added 1 commit

    added 1 commit

    Compare with previous version

  • 7
    8 /**
    9 * Defines a compiler pass to merge moved classes into a single container parameter.
    10 */
    11 class BackwardsCompatibilityClassLoaderPass implements CompilerPassInterface {
    12
    13 /**
    14 * {@inheritdoc}
    15 */
    16 public function process(ContainerBuilder $container): void {
    17 $moved_classes = $container->getParameter('core.moved_classes');
    18 $modules = array_keys($container->getParameter('container.modules'));
    19 foreach ($modules as $module) {
    20 $parameter_name = $module . '.moved_classes';
    21 if ($container->hasParameter($parameter_name)) {
    22 $moved_classes = $moved_classes + $container->getParameter($parameter_name);
    • I think we should validate that the 'class' value exists and error if it does not - that way we'll know when we break this even if there are no more old usages.

      Also if two modules alias the same class what does that mean? Atm the first one wins.

    • Author Maintainer

      I'm not sure what you mean by validating the class value exists, do you mean on every array value of the moved_classes array or just one?

      I think first one wins for two modules aliasing the same class is probably fine? In practice modules should only alias their own classes, if they alias another module's class, then they're either doing something very tricky on purpose, or made a mistake, but not sure how we'd know which is which.

    • I think

      $module_moved = $container->getParameter($parameter_name);
      \assert(is_array($module_moved));
      \assert(count($module_moved) === count(array_column($module_moved', 'class')), 'Missing class key for moved classes');

      Will cover what Alex is asking for

    • catch changed this line in version 9 of the diff

      changed this line in version 9 of the diff

    • Author Maintainer

      Ah OK that makes sense, added the asserts.

    • Please register or sign in to reply
  • godotislate
  • catch added 1 commit

    added 1 commit

    • bcc66178 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • godotislate
  • catch added 1 commit

    added 1 commit

    • ed8419e8 - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • catch added 134 commits

    added 134 commits

    • ed8419e8...75ea9ab7 - 124 commits from branch project:11.x
    • 79726c03 - Initial proof of concept.
    • b4b54022 - Add support for container parameters, deprecation handling, and test coverage.
    • 9dd53421 - Add backwards compatibility classloader.
    • 2ab57e94 - Move parameter merging to the container, make deprecation message fit the standard.
    • 84b00202 - Add missing file.
    • c081ae37 - Add missing services.yml
    • 50c0da4d - whitespace
    • af6457f0 - Apply 1 suggestion(s) to 1 file(s)
    • 6175c1c2 - Apply 1 suggestion(s) to 1 file(s)
    • 813e28f8 - Add assert for moved classes structure.

    Compare with previous version

  • godotislate
  • godotislate
  • catch added 1 commit

    added 1 commit

    • 1074295e - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • catch added 1 commit

    added 1 commit

    • 36a2777a - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • catch added 1 commit

    added 1 commit

    Compare with previous version

  • Please register or sign in to reply
    Loading