Problem/Motivation

#1577902: [META] Remove all usages of drupal_static() & drupal_static_reset() wants us to get rid of drupal_static().

#3015538: [META] Deprecate contents of common.inc wants us to deprecate functions in common.inc.

Thus here we feet two birds with one seed.

Proposed resolution

Move the functionality of drupal_get_updaters() into a static method on Drupal\Core\Updater\Updater. Let's call it getUpdaterRegistry().

Instead of using drupal_static() to cache in memory, we'll add a static property to Drupal\Core\Updater\Updater.

Deprecate drupal_get_updaters() in favor of Updater::getUpdaterRegistry().

Remaining tasks

  • Feedback from #25

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3036010

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Mile23 created an issue. See original summary.

mile23’s picture

Status: Active » Needs review
StatusFileSize
new8.57 KB

Let's try a patch.

Status: Needs review » Needs work

The last submitted patch, 2: 3036010_2.patch, failed testing. View results

andypost’s picture

Issue tags: +@deprecated, +Kill includes

Looking at usage I started to think that better to refactor it out of hooks at all. It looks more like event needed here.
On other hand in a light of composer this subsystem is very debatable

mile23’s picture

Issue summary: View changes
mile23’s picture

StatusFileSize
new9.73 KB
new1.38 KB

Reroll after #3000057: Deprecate drupal_set_time_limit() and file_upload_max_size() and move to Environment component, fixed failing tests, removed usages from docs.

I think a lot of this will be refactored for #2367319: Implement automatic background updates for highly critical security issues and similar issues.

mile23’s picture

Status: Needs work » Needs review

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

claudiu.cristea’s picture

+++ b/core/includes/common.inc
@@ -1294,18 +1295,16 @@ function archiver_get_archiver($file) {
+ * @deprecated in Drupal 8.7.0 for removal before Drupal 9.0.0. Use
...
+  @trigger_error(__FUNCTION__ . '() is deprecated in Drupal 8.7.0 for removal before Drupal 9.0.0. Use \Drupal\Core\Updater\Updater::getUpdaterRegistry() instead. See change record.', E_USER_DEPRECATED);

+++ b/core/tests/Drupal/KernelTests/Core/Updater/DeprecatedDrupalGetUpdatersTest.php
@@ -0,0 +1,20 @@
+   * @expectedDeprecation drupal_get_updaters() is deprecated in Drupal 8.7.0 for removal before Drupal 9.0.0. Use \Drupal\Core\Updater\Updater::getUpdaterRegistry() instead. See change record.

Needs to increment the Drupal version to 8.8.0. This should be done also in CR (oh, no CR).

mile23’s picture

Status: Needs review » Needs work
Issue tags: +Needs change notice
claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record, -Needs change notice
StatusFileSize
new11.57 KB
new4.99 KB
+++ b/core/includes/common.inc
@@ -1294,18 +1295,16 @@ function archiver_get_archiver($file) {
-  $updaters = &drupal_static(__FUNCTION__);

What if a 3rd party code is doing this?

drupal_static_reset('drupal_get_updaters');

The current code allows resetting the memory cache but the patch has removed that ability. So, we need a reset cache mechanism and also deprecate the usage of drupal_static_reset('drupal_get_updaters').

Fixed the above. Also moved to 8.8.x and added CR.

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

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). 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: 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.

hardik_patel_12’s picture

Issue tags: +Bug Smash Initiative
StatusFileSize
new10.59 KB

Re-rolling against 9.1.x-dev.

Status: Needs review » Needs work

The last submitted patch, 14: 3036010-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

hardik_patel_12’s picture

Issue tags: -Bug Smash Initiative
hardik_patel_12’s picture

Drupal 9 was released, so we need to update the deprecation messages.

naresh_bavaskar’s picture

Assigned: Unassigned » naresh_bavaskar
andypost’s picture

Assigned: naresh_bavaskar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.25 KB
new10.65 KB

Proper re-roll (messages fixed) and clean-up

Also improved test
- module should test that data returned from old method
- no reason to split into 2 methods as both coupled and core installs twice for no reason

EDIT

+++ b/core/modules/update/src/Form/UpdateManagerInstall.php
@@ -199,9 +199,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
-    // Make sure the Updater registry is loaded.
-    drupal_get_updaters();

+++ b/core/modules/update/src/Form/UpdateReady.php
@@ -127,9 +127,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
-      // Make sure the Updater registry is loaded.
-      drupal_get_updaters();

Removed to make sure that static does not affect

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.

longwave’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs reroll and deprecated versions updating.

claudiu.cristea’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
  • Rerolled
  • Fixed the Drupal version in deprecation messages, including the change record.
  • Converted @expectedDeprecation annotation into assertions $this->expectDeprecation().
longwave’s picture

Should we just deprecate resetRegistryCache() as well, there seems little point in keeping it. No uses of drupal_get_updaters in contrib, let alone the static: http://grep.xnddx.ru/search?text=drupal_get_updaters&filename=

I'm not even sure I see the point in hook_updater_info, the only implementation is in system.module, but that's a wider issue - do we even really support updating anything else?

daffie’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The remark from @longwave in #25 still needs to be addressed.
The patch looks good to me!.

dhirendra.mishra’s picture

StatusFileSize
new10.87 KB

I have manually re-rolled it against 9.3.x

sokru’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new10.59 KB
new1.4 KB

Patch on #27 failed to apply, so another try with reroll.

Status: Needs review » Needs work

The last submitted patch, 28: 3036010-28.patch, failed testing. View results

vsujeetkumar’s picture

Status: Needs work » Needs review
StatusFileSize
new10.64 KB
new2.68 KB

Re-roll patch #27 is not appropriate, We missed some previous fixed changes according to #24. Please have a look.

Uploaded the updated patch for 9.3.x.

daffie’s picture

Status: Needs review » Needs work

The remark from @longwave in #25 still needs to be addressed.

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.

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.

kim.pepper’s picture

Status: Needs work » Needs review
StatusFileSize
new10.76 KB

Reroll for 10.1.x.

kim.pepper’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 35: 3036010-35.patch, failed testing. View results

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

Pretty sure this can be closed as outdated.

This function was deprecated outright.

The comment in 25 confused me until I realized it was just about deprecating the newly introduced static.

nicxvan’s picture

Status: Needs work » Closed (outdated)

Compared the patches with the current state to confirm the deprecation covered everything in this.

The only thing this does that the main deprecation issue doesn't is deprecating calling drupal_static_reset for the function, but since the function is deprecated that seems fine to me.

Took a look at patches to apply credit as well since closed issues receive credit now.

I'm glad MRs are the primary way to review code, even with inter diffs patches are harder without the ui.

Thanks everyone for working on this!