Resolve #3502882 "Bc classloader"
Closes #3502882
Merge request reports
Activity
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); From this example: https://www.drupal.org/about/core/policies/core-change-policies/how-to-deprecate#s-concrete-instantiated-classes, maybe the deprecation message should something more like
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); 39 @trigger_error(sprintf('%s is deprecated in %s and is removed from %s. Use %s instead. See %s', $class, $moved['deprecation_version'], $moved['removed_version'], $moved['class'], $moved['change_record_url']), E_USER_DEPRECATED); Would also need to add the change_record_url property to the parameter scheme (and/or logic needed to detect where there is one).
changed this line in version 3 of the diff
added 1 commit
- c3e6a9ef - Move parameter merging to the container, make deprecation message fit the standard.
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'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.
changed this line in version 9 of the diff
- Resolved by catch
- Resolved by catch
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.
Toggle commit list-
ed8419e8...75ea9ab7 - 124 commits from branch
- Resolved by catch
- Resolved by catch