Comments

dpi created an issue. See original summary.

dpi’s picture

dpi’s picture

StatusFileSize
new8.15 KB

Working from here, posting patch to date

sam152’s picture

+++ b/src/Entity/Linky.php
@@ -37,15 +38,24 @@ use Drupal\user\UserInterface;
+ *   revision_table = "linky_revision",
+ *   revision_data_table = "linky_field_revision",
+ *   show_revision_ui = TRUE,
...
+ *     "revision" = "revision_id",
...
+ *   revision_metadata_keys = {
+ *     "revision_user" = "revision_uid",
+ *     "revision_created" = "revision_created",
+ *     "revision_log_message" = "revision_log"
+ *   },

Wondering if these keys also need to be manually installed on the entity type definition?

If you want to test this out, any entity query against linky entities should fail if these keys haven't been installed on the entity type definition.

jibran’s picture

+++ b/src/Entity/Linky.php
@@ -37,15 +38,24 @@ use Drupal\user\UserInterface;
+ *   revision_data_table = "linky_field_revision",

This is used if the entity is translateable which linky is not so this can be removed.

jibran’s picture

+++ b/linky.post_update.php
@@ -0,0 +1,95 @@
+  $revisionCreatedField = BaseFieldDefinition::create('created')
...
+    ->setInitialValueFromField('changed');
...
+  $update->expression('revision_created', 'changed');

You don't need $update->expression('revision_created', 'changed'); if you set >setInitialValueFromField('changed'); for $revisionCreatedField.

dpi’s picture

+ *   revision_data_table = "linky_field_revision",

This is used if the entity is translateable which linky is not so this can be removed.

Will do.

You don't need $update->expression('revision_created', 'changed'); if you set >setInitialValueFromField('changed'); for $revisionCreatedField.

I cannot do this, check the update hook method docs.

Wondering if these keys also need to be manually installed on the entity type definition?

Looking into it

dpi’s picture

Wondering if these keys also need to be manually installed on the entity type definition?

If you want to test this out, any entity query against linky entities should fail if these keys haven't been installed on the entity type definition.

Tried this immediately after a drush updatedb without clearing cache without issue.

Also Drupal status page reports no issues with entity schemas...

jibran’s picture

Status: Active » Needs work

Let's bump the min core version and use the new API.

because we should never rely on live entity type or field definitions in an update function

amateescu’s picture

FWIW, as the author of both the new (EntityDefinitionUpdateManager::updateFieldableEntityType()) and the old (SqlContentEntityStorageSchemaConverter) API, I chose not to use the old API for converting taxonomy terms and menu links to revisionable in core 8.6.x, and wrote the new API for 8.7.x for the reason quoted in #10.

I also maintain a fairly used D8 module (Entityqueue, with ~9.000 installs) where I need to do the same conversion to revisionable, and I will bump the requirements in order to be able to use the new API :)

dpi’s picture

Status: Needs work » Needs review
StatusFileSize
new9.88 KB
new7.92 KB

Thanks @amateescu, and @jibran for the encouragement,

Updated patch to use 8.7 methods, raised requirements.

Notably using set-initial-value methods seem to be useless; modified data migration path accordingly.

jibran’s picture

Thanks, for addressing the feedback. The patch is looking good.
Can we have some upgrade path tests, please?

dpi’s picture

StatusFileSize
new873 bytes
new10.09 KB

Gonna need these fields ;)

Status report no longer complains about mismatches.

amateescu’s picture

  1. +++ b/composer.json
    @@ -10,5 +10,7 @@
    +    "drupal/core": "~8.7.0"
    

    This isn't needed because Drupal only looks at the dependencies defined in the linky.info.yml file.

    Removing it should also fix the testbot failure.

  2. +++ b/linky.post_update.php
    @@ -0,0 +1,119 @@
    +function linky_post_update_revisionable_data_revision_date(&$sandbox) {
    

    This is not needed as well, the entity update API does it for you :)

dpi’s picture

This is not needed as well, the entity update API does it for you :)

I’m afraid I’m not seeing it.

jibran’s picture

  1. +++ b/linky.post_update.php
    @@ -0,0 +1,119 @@
    +    ->setInitialValueFromField('user_id');
    ...
    +r.revision_uid = base.user_id');
    

    setInitialValueFromField should set it up, rigth?

  2. +++ b/linky.post_update.php
    @@ -0,0 +1,119 @@
    +r.revision_created = r.changed,
    

    We might need this because they are different field types.

jibran’s picture

+++ b/src/Entity/Linky.php
@@ -149,7 +172,6 @@ class Linky extends ContentEntityBase implements LinkyInterface {
       ->setDefaultValueCallback('Drupal\node\Entity\Node::getCurrentUserId')

Why is this using node function?

dpi’s picture

Pre-existing

jibran’s picture

StatusFileSize
new11.56 KB
new13.19 KB

Addressed #15.1
#15.2 is need without table is showing default field values.
Fixed #18 and clean up the Linky::baseFieldDefinitions() method and removed the redundent methods.

jibran’s picture

StatusFileSize
new3.2 KB
new13.84 KB

There was ID mismatch so added update hook for that.

Status: Needs review » Needs work

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

jibran’s picture

+++ b/linky.install
@@ -0,0 +1,31 @@
+  $entity_field_manager = \Drupal::service('entity_field.manager');
+  $entity_field_manager->clearCachedFieldDefinitions();
...
+  $storage_definition = $entity_field_manager->getFieldStorageDefinitions('linky')['id'];

I think this is causing

 [error]  Update aborted by: linky_update_8101 

 [error]  Finished performing updates. 

> [error] The entity type linky does not have an "owner" entity key.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new1.75 KB
new14.03 KB

It might fix #23.

jibran’s picture

StatusFileSize
new477 bytes
new14.11 KB

Added desc as well.

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

Status: Needs review » Needs work

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

dpi’s picture

Status: Needs work » Needs review
StatusFileSize
new14.59 KB

Tracking https://github.com/dpi/linky/pull/1

Many changes on 8.x-1.x today, rerolled 25 against it. No other changes.

HEAD tests also fixed so this should go green

Status: Needs review » Needs work

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

dpi’s picture

Assigned: dpi » Unassigned

Interesting fails to be happening at this point in time.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new484 bytes
new14.77 KB

This might fix it.

jibran’s picture

StatusFileSize
new2.46 KB
new14.82 KB

With PHPCS fixes.

jibran’s picture

jibran’s picture

StatusFileSize
new23.14 KB
new37.96 KB

First pass for the upgarde path.

Status: Needs review » Needs work

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

jibran’s picture

Assigned: Unassigned » dpi
Status: Needs work » Needs review
StatusFileSize
new4.74 KB
new24.78 KB

Update path test is working now.

@amateescu I commented out linky_post_update_set_default_revisionable_data. And the failing test will show that setInitialValueFromField is not working properly. Is there something I'm missing or is it a core bug?

Status: Needs review » Needs work

The last submitted patch, 36: 3052102-36.patch, failed testing. View results

amateescu’s picture

Yeah, setInitialValueFromField() only works during a "regular" field install operation. not during entity schema migrations like we're doing here.

A workaround would be to create those fields that need initial values in a hook_update_N() function, which always runs before to the post_update one.

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new1.17 KB
new19.21 KB

Reroll after the latest release.

RE #38: I like the current state linky_post_update_make_linky_revisionable. Splitting it into hook_update_N means moving bunch of stuff around so I'd say let's leave that and re-instate the linky_post_update_set_default_revisionable_data.

jibran’s picture

StatusFileSize
new24.88 KB

Now with --binary

Status: Needs review » Needs work

The last submitted patch, 40: 3052102-40.patch, failed testing. View results

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new8.66 KB
new24.82 KB

Moved linky_post_update_make_linky_revisionable to linky_update_8102

Status: Needs review » Needs work

The last submitted patch, 42: 3052102-42.patch, failed testing. View results

jibran’s picture

Status: Needs work » Needs review
StatusFileSize
new668 bytes
new24.89 KB

This should fix. Ignore #42. Interdiff is from #40.

acbramley’s picture

StatusFileSize
new18.93 KB

Reroll of #44

Status: Needs review » Needs work

The last submitted patch, 45: 3052102-45.patch, failed testing. View results

jibran’s picture

@acbramley, I thought you were not intrested in this issue. :D

acbramley’s picture

Status: Needs work » Needs review
StatusFileSize
new24.93 KB

Now including the db fixture.

jibran’s picture

I think the patch needs a reroll after #3097042: Drupal 9 readiness.

dpi’s picture

Assigned: dpi » Unassigned
StatusFileSize
new1.14 KB
new24.92 KB

Fixed D9 compat.

The interdiff doesnt show it but there was a schema version entry removal for link module.

jibran’s picture

+++ b/src/Entity/Linky.php
@@ -136,23 +105,19 @@ class Linky extends ContentEntityBase implements LinkyInterface {
       ->setDefaultValueCallback(static::class . '::getDefaultEntityOwner')

This not needed anymore.

  • acbramley committed de9f6d0 on 8.x-1.x authored by dpi
    Issue #3052102 by jibran, dpi, acbramley, amateescu, Sam152: Convert...
acbramley’s picture

Status: Needs review » Fixed

This not needed anymore.

Fixed on commit 🎉

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.