EntityLocationFieldInstance & LocationFieldStorage do not count source items correctly

Created on 13 January 2021, almost 4 years ago
Updated 3 June 2024, 7 months ago

Problem/Motivation

I am migrating a Drupal 7 site that has locations attached to 6 content types:

MariaDB [drupal7]> select name from variable where name like 'location_settings_node_%';
+------------------------------------+
| name                               |
+------------------------------------+
| location_settings_node_article     |
| location_settings_node_distributor |
| location_settings_node_download    |
| location_settings_node_page        |
| location_settings_node_product     |
| location_settings_node_webform     |
+------------------------------------+
6 rows in set (0.000 sec)

This shows up as 6 items in migrate status:

$ ddev exec drush ms upgrade_d7_entity_location_field_node
 ----------------------------------------- --------------------------------------- -------- ------- ---------- ------------- --------------- 
  Group                                     Migration ID                            Status   Total   Imported   Unprocessed   Last Imported  
 ----------------------------------------- --------------------------------------- -------- ------- ---------- ------------- --------------- 
  Import from Drupal 7 (migrate_drupal_7)   upgrade_d7_entity_location_field_node   Idle     6       0          6                            
 ----------------------------------------- --------------------------------------- -------- ------- ---------- ------------- --------------- 

However, on running this migration only two items are migrated, and this means the subsequent migrations cannot run because they think this one has not completed:

$ ddev exec drush mim upgrade_d7_entity_location_field_node
 [notice] Processed 2 items (2 created, 0 updated, 0 failed, 0 ignored) - done with 'upgrade_d7_entity_location_field_node'

$ ddev exec drush ms upgrade_d7_entity_location_field_node
 ----------------------------------------- --------------------------------------- -------- ------- ---------- ------------- --------------------- 
  Group                                     Migration ID                            Status   Total   Imported   Unprocessed   Last Imported        
 ----------------------------------------- --------------------------------------- -------- ------- ---------- ------------- --------------------- 
  Import from Drupal 7 (migrate_drupal_7)   upgrade_d7_entity_location_field_node   Idle     6       2          4             2021-01-13 21:33:08  
 ----------------------------------------- --------------------------------------- -------- ------- ---------- ------------- --------------------- 

$ ddev exec drush mim upgrade_d7_entity_location_field_instance_node_article
 [error]  Migration upgrade_d7_entity_location_field_instance_node_article did not meet the requirements. Missing migrations upgrade_d7_entity_location_field_node. requirements: upgrade_d7_entity_location_field_node. 

Steps to reproduce

Proposed resolution

Override the EntityLocationFieldStorage::count() method so it returns the correct number of results.

Alternatively, override the ::query() method so it returns the correct data to begin with.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom longwave UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Also ran into this issue when running 'migration:import --update' after adding the location_migration module and was having the same issue despite running the 'required migrations'. The #13 patch worked as described, thanks @huzooka.
    Is there anything missing that is holding this back from being merged?

Production build 0.71.5 2024