Problem/Motivation

In #2429191: Deprecate entity_reference.module and move its functionality to core we deprecated the entity reference module but this was before most of was written. This issue is going to explore:

  • Properly deprecating all the module code
  • How to deprecate a module

The aim is to ensure that we can safely remove this module and explore whether we should add a generic deprecated key to info.yml.

There are probably going to be issues with tests that are very generic and install all the available modules so we'll need to deal with the consequences.

Proposed resolution

Remaining tasks

User interface changes

tbd

API changes

tbd

Data model changes

None

Release notes snippet

tbd

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new5.7 KB

Status: Needs review » Needs work

The last submitted patch, 2: 3062302-2.patch, failed testing. View results

catch’s picture

One important thing with module deprecation is we need to ensure the module is actually uninstalled before it's removed from the code base.

This could mean:

- Including an update with 9.0.0 that uninstalls the module, leaving just the .info.yml (but with installation prevented somehow) to allow that process to happen. Then physically removing the .info.yml in 10.x

- requiring manual uninstallation prior to a 9.x/10.x update

If modules are moving to contrib this isn't as important, but for actual removals we need to figure out how to manage it.

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.

andypost’s picture

Probably better to add another update hook to uninstall module (the field_update_8002() already removes config

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new9.28 KB

Reroll and removing usages, many tricky ones can be fixed by just adding it to \Drupal\Tests\DeprecatedModulesTestTrait, thanks to the work done in the block_place issue.

berdir’s picture

About the removal, not having the module around anymore results in some user notices, but nothing is broken.

On 8.9.x, do drush en -y entity_reference
switch to 9.0.x, rm -rf core/modules/entity_reference

Visit /update.php

Shows User warning: The following module is missing from the file system: entity_reference in drupal_get_filename() (line 188 of core/includes/bootstrap.inc), but you can run updates.

And at this point, the update system already purged entity_reference from core.extension. The reason that the user notice doesn't go away is because we still have the system.schema key value definition for it, so the update system tries to get its update functions.

What if we just add a system_update_900x() that manually cleans up that record (removing it from core.extension but not key_value is IMHO a bug anyway) if you really still have it enabled?

Too late to get this into 8.8.0, but even though we didn't enforce it so far and had a few left-over tests in core, I expect barely any site actually still has this module enabled, as this happened very early in the D8 cycle (8.0.0-rc1 seems to be the first tag to have the commit).

alexpott’s picture

Looks like we need to fix update_fix_compatibility()

andypost’s picture

naresh_bavaskar’s picture

Assigned: Unassigned » naresh_bavaskar
catch’s picture

Status: Needs review » Reviewed & tested by the community

#7 looks RTBC to me.

Opened #3111645: Uninstall entity_reference module and prevent it being enabled again, remove deprecated code for 9.x to remove the code we're deprecating here, and properly prepare the module for actual removal.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 3062302-7.patch, failed testing. View results

ravi.shankar’s picture

Status: Needs work » Reviewed & tested by the community

I think it is unrelated test failures, so making it RTBC as per @catch's comment #12.

catch’s picture

Status: Reviewed & tested by the community » Needs work

The test failures in #7 aren't unrelated, we need to add @group legacy to that test unfortunately.

wim leers’s picture

Issue tags: +Novice, +Needs reroll

For #15.

gábor hojtsy’s picture

Status: Needs work » Needs review
Issue tags: -Novice, -Needs reroll
StatusFileSize
new816 bytes
new10.08 KB

Is this what we need here? I am not exactly sure this is Novice :D At least I was not sure if I am doing this right.

Status: Needs review » Needs work

The last submitted patch, 17: 3062302-17.patch, failed testing. View results

gábor hojtsy’s picture

Hm, that is not what we need.

catch’s picture

We should only be deprecating any actual APIs or plugins here I think. And a hook_requirements() runtime warning if the module is enabled if we didn't already do that.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new8.96 KB
new2.71 KB

Copied over the requirements hook that we did in 9.0.x and removed the @trigger_error() from the .module file, I think that's what you meant by only deprecating actual API's here?

If we do that (which is IMHO what we should have done with block_place.module too), then I think we don't need to change DeprecatedModulesTestTrait, lets see.

berdir’s picture

Ok, green. Do we need some explicit BC tests here?

catch’s picture

Status: Needs review » Reviewed & tested by the community

IMO we don't need explicit test coverage here - it's not really providing a bc layer as such, it's just (hopefully) dead code by now.

So I think this is ready to go.

alexpott’s picture

So this change is going to affect contrib...

  • authbucket
  • barrio
  • bear
  • bibcite_footnotes
  • block_formatter
  • bt_media
  • content_entity_student
  • dea
  • degov
  • druponent
  • erpal_core
  • facets_active_entity_block
  • facets_active_view_block
  • fancy_kickstart
  • file_entity_browser_ui_testing
  • invoicer
  • juicebox
  • link_to_entity
  • lissa_kickstart
  • media_dev
  • media_pinkeye
  • menu_formatter

Add thats only the first 18 or so pages - I go to http://grep.xnddx.ru/search?text=-%20entity_reference&filename=&page=17

What's odd is that we're preventing install but allowing it still to be installed so existing sites will still work. If the site has any sort of rebuild to dev workflow though this is going to break them.

What's interesting is that I think we'd highlight the problem better by just removing the module...

naresh_bavaskar’s picture

Assigned: naresh_bavaskar » Unassigned
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/entity_reference/entity_reference.install
@@ -0,0 +1,26 @@
+  if ($phase === 'install') {
+    $requirements['entity_reference'] = [
+      'title' => t('Entity Reference: Deprecated'),
+      'description' => t('Entity Reference is deprecated, all functionality has been moved to Core.'),
+      'value' => \Drupal::VERSION,
+      'severity' => REQUIREMENT_ERROR,
+    ];
+  }

I hadn't realised this was an 8.x patch only. So I think this is very tricky. As a site owner you might not be able to fix the contrib module that depends on entity_reference. So at the very least this should be runtime only. But maybe also only a warning. And potentially we should detail why this is being installed / required (that should also be in the D9 version of this).

catch’s picture

Status: Needs work » Needs review

@alexpott - looking at those grep results, they all look like references to https://www.drupal.org/project/entity_reference_revisions, not entity_reference?

We're trying to prevent the module from being installed, so that once it's uninstalled, it won't be re-enabled again before 9.x actually deletes it from the file system.

joachim’s picture

+++ b/core/modules/entity_reference/entity_reference.install
@@ -0,0 +1,26 @@
+      'description' => t('Entity Reference is deprecated, all functionality has been moved to Core.'),

That's ambiguous... the Entity Reference module IS in core!

Maybe 'the entity Core subsystem' would be clearer?

berdir’s picture

> Maybe 'the entity Core subsystem' would be clearer?

It's not correct though. It has been moved to Core\Entity, but also system.module and views.module.

joachim’s picture

'has been moved to other parts of core'?

alexpott’s picture

@catch re #27 nope all those projects have a dependency on entity reference - see https://git.drupalcode.org/project/degov/blob/8.x-6.x-dev/degov.info.yml for example.

catch’s picture

hmm OK let's just make this a runtime warning in 8.x then.

#3111645: Uninstall entity_reference module and prevent it being enabled again, remove deprecated code was the 9.x issue here, which turns the module into a stub, uninstalls it, prevents it being reinstalled. For actual removal in 10.x (not what I said in #27...).

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.

xjm’s picture

I filed #3135100: [policy and meta] Provide a proper mechanism for deprecating modules and themes (which was supposed to have been filed like eight months ago, but oh well).

We missed the boat to do this in D8, I think? But the stub is still there in D9, so we still need to do something prior to D10.

catch’s picture

Priority: Normal » Major

Bumping priority.

ravi.shankar’s picture

StatusFileSize
new7.69 KB

Patch #21 is not applying anymore so, here I have added a re-roll of patch #21 for Drupal 8.9.x.

hardik_patel_12’s picture

StatusFileSize
new2.41 KB
new4.28 KB

Patch #36 is failed to apply on for Drupal 9.1.x , kindly follow a new patch.

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.

tanubansal’s picture

Patch #37 is successfully working on 9.1

longwave’s picture

Version: 9.2.x-dev » 8.9.x-dev
Status: Needs review » Needs work

This got auto-bumped to 9.x, but I think there is nothing to do in 9.x yet? We can still add a runtime warning in 8.x as per #32, but is it even worth doing that now?

xjm’s picture

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

I think we should not backport anything related to this to 8.9.x. That is a long-term support branch restricted to non-disruptive changes. This is for completing the deprecation and removal safely so there's nothing left of it in our codebase in D10.

For this issue, we should perhaps also make it so that the stub module can't be installed on new sites (See #3112432: Prevent core, stub simpletest module from being installed on new sites for example), and then later consider the update hook option to uninstall it from existing sites.

Some of these are things we would commit to 9.2.x.

longwave’s picture

@xjm we already uninstalled it on existing sites and prevented it from being installed again in #3111645: Uninstall entity_reference module and prevent it being enabled again, remove deprecated code

xjm’s picture

So is there anything else to do here, or should we simply close this and open a postponed D10 issue to rm -rf the wrapper?

catch’s picture

I think #43 is the correct course of action here.

gábor hojtsy’s picture

Status: Needs work » Closed (duplicate)

Opened #3188858: Remove the entity_reference module entirely on the Drupal 10 branch, see you there. Closing this as duplicate then, since we did not "fix" anything here per say.