I copy-pasted an update hook from module A into module B's b.post_update.php, as a_my_post_update(), and the update system found it and didn't mind and reported it as belonging to module A.

It should probably throw an exception instead.

Comments

joachim created an issue. See original summary.

joachim’s picture

Probably not easy to fix, since getAvailableUpdateFunctions() just looks at get_defined_functions() rather than look in each file.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

borisson_’s picture

Issue tags: +Bug Smash Initiative

Probably not easy to fix, since getAvailableUpdateFunctions() just looks at get_defined_functions() rather than look in each file.

Looks like this would be possible with Reflection (https://www.php.net/manual/en/reflectionfunctionabstract.getfilename.php)

Since this is a developer experience improvement, I'm not sure if this is a bug or a task, this feels more like a task.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nicxvan’s picture

Component: base system » extension system
nicxvan’s picture

Status: Active » Postponed (maintainer needs more info)

This is how hooks worked in procedural land.

We intentionally preserved that with attributes (though it's under discussion)

I would presume we'd preserve that as well if these mive to oop too.

This might not belong with the extension system, but sure exactly where it should be though.

nicxvan’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

I'm going to close this as works as designed.

While it might be kind of confusing it is how it works.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.