Problem/Motivation

This is a followup to #3086238: getHighestId() should not fail when there is a destination id with type string. Well, actually this reduces the scope of that one.

While working on #2746541: Migrate D6 and D7 node revision translations to D8 it was discovered that Sql::getHighestId() always returns the highest value for the first destination field, destid1. This is fine for all current core migrations. However, in a node master migration likely to be introduced for handling the migration of node revision translations and entity translation revisions we will need to get the highest revision Id. So some changes are needed to allow that to happen.

And this needs to work easily with the Audit interface, particularly IdAuditor::audit().

Proposed resolution

Deprecate getHighestId() and introduce a new method getMaximal($id_name = NULL) that will accept an input parameter. The new method will use that parameter if it exists, and if not it will keep the legacy behavior, which is to return the highest ID of the first destination id. The new method will also allow for a destination id to be a non-integer.

Remaining tasks

Decide on the name for the new method, currently getMaximalId()
Make a patch, with tests
Review

Comments

quietone created an issue. See original summary.

quietone’s picture

Here is the work in progress patch from #3086238: getHighestId() should not fail when there is a destination id with type string before that was reduced in scope.

There is some credit in the originating issue that needs to be consider, larowlan, heddn, dinarcon and Gábor Hojtsy all contributed reviews.

quietone’s picture

Issue summary: View changes
quietone’s picture

The current patch doesn't work nicely with IdAuditor::audit() and that needs some thought and ideas.

mikelutz’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/migrate/src/Audit/HighestIdInterface.php
    @@ -20,7 +20,24 @@
    +   * @deprecated getHighestId() is deprecated in drupal:8.9.0 and is removed
    +   * from drupal:9.0.0. Use getMaximalId() instead.
    +   * See http://drupal.org/node/3089609
    

    We cannot deprecate in drupal:8.9.0 for removal in drupal:9.0.0. The RMs are still deciding whether we will deprecate in 8.9 and remove in 10.0.0 or wait until 9.1 to add the deprecation.

  2. +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php
    @@ -402,6 +402,14 @@ protected function getDefinitionFromEntity($key) {
       public function getHighestId() {
    +    @trigger_error('getHighestId() is deprecated in drupal:8.9.0 and is removed from drupal:9.0.0. Use getMaximalId() instead. See http://drupal.org/node/3089609', E_USER_DEPRECATED);
    +    $this->getMaximalId();
    
    +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php
    @@ -202,6 +202,14 @@ public function getIds() {
       public function getHighestId() {
    +    @trigger_error('getHighestId() is deprecated in drupal:8.9.0 and is removed from drupal:9.0.0. Use getMaximalId() instead. See http://drupal.org/node/3089609', E_USER_DEPRECATED);
    +    $this->getMaximalId();
    

    Same here. We may just want to leave both methods in for now.

dinesh18’s picture

Status: Needs work » Needs review
StatusFileSize
new11.64 KB
new1.94 KB

Here is the updated patch and interdiff as per #5

mikelutz’s picture

Status: Needs review » Needs work

I'm setting this to NW for #4

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.

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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.