Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'v got a very strange error:
root@6b2a6a5baae4:/var/www/html# vendor/bin/drush migrate:import organization_xls --update
[warning] Invalid argument supplied for foreach() Migration.php:634
[warning] Invalid argument supplied for foreach() Migration.php:634
[error] Error: Undefined class constant 'SOURCE_IDS_HASH' in Drupal\migrate\Plugin\migrate\id_map\Sql->saveIdMapping() (line 644 of /var/www/html/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php) #0 /var/www/html/core/modules/migrate/src/MigrateExecutable.php(231): Drupal\migrate\Plugin\migrate\id_map\Sql->saveIdMapping(Object(Drupal\migrate\Row), Array, NULL, 0)
#1 /var/www/html/vendor/drush/drush/includes/drush.inc(232): Drupal\migrate\MigrateExecutable->import()
#2 /var/www/html/vendor/drush/drush/includes/drush.inc(223): drush_call_user_func_array(Array, Array)
#3 /var/www/html/modules/migrate_tools/src/Commands/MigrateToolsCommands.php(766): drush_op(Array)
#4 [internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->executeMigration(Object(Drupal\migrate\Plugin\Migration), 'organization_xl...', Array)
#5 /var/www/html/modules/migrate_tools/src/Commands/MigrateToolsCommands.php(321): array_walk(Array, Array, Array)
#6 [internal function]: Drupal\migrate_tools\Commands\MigrateToolsCommands->import('organization_xl...', Array)
#7 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#8 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#9 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(178): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#10 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#11 /var/www/html/vendor/symfony/console/Command/Command.php(251): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/vendor/symfony/console/Application.php(964): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(112): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(41): Drush\Runtime\Runtime->doRun(Array)
#17 /var/www/html/vendor/drush/drush/drush.php(66): Drush\Runtime\Runtime->run(Array)
#18 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
#19 {main}.
PHP version:
root@6b2a6a5baae4:/var/www/html# php --version
PHP 7.0.33-0+deb9u1 (cli) (built: Dec 7 2018 11:36:49) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33-0+deb9u1, Copyright (c) 1999-2017, by Zend Technologies
This issue only exist for PHP 7.0. PHP 7.1 & 7.2 does not have this issue.
Comment | File | Size | Author |
---|---|---|---|
#25 | 3034599-25.patch | 8.95 KB | alexpott |
#25 | 19-25-interdiff.txt | 6.01 KB | alexpott |
#19 | 3034599-19.patch | 8.42 KB | heddn |
#17 | 3034599-17-tests_only.patch | 2.91 KB | heddn |
Comments
Comment #2
jian he CreditAttribution: jian he commentedComment #3
jian he CreditAttribution: jian he commentedComment #4
jian he CreditAttribution: jian he commentedGot it at last.
Change static::SOURCE_IDS_HASH to self::SOURCE_IDS_HASH will solve this issue.
Comment #5
jian he CreditAttribution: jian he commentedThere has similar error on line 663:
Doing the same change will solve it.
Comment #6
jian he CreditAttribution: jian he commentedFix #5
Comment #8
grahamCI've just encountered this too on 8.7.x - basically prevents import/rollback of any migrations on php 7.0.
Looks like something triggering a subtle bug in PHP 7.0's implementation of late static binding:
get_called_class()
when in thedeleteDestination()
method:- outputs
"Drupal\migrate_tools\IdMapFilter"
on 7.0- instead of
"Drupal\migrate\Plugin\migrate\id_map\Sql"
on PHP 7.1.From my understanding, swapping
static::
forself::
would mean that subclasses can no longer override that constant...Comment #9
heddnAny chance for a test? NW for tests.
Comment #10
heddnLet's see if this exposes the issue on php 7.0.
Comment #11
heddnComment #12
heddn#11 is just a re-post of #6 so it is last on the list.
Comment #13
heddnHmm, the tests aren't failing like I expected. Let's get some of the work from the upstream issue pulled down here into a test issue.
Comment #14
heddnLet's see if this reproduces the failures.
Comment #15
catchComment #16
heddnThose failures all along here seem random. However https://www.drupal.org/pift-ci-job/1252333 is a consistent failure. Still looking into what is the cause of these.
Comment #17
heddnThe differences here are that in migrate tools we have a batch executable. Which I assume gets serialized or something at some point. But also of issue is that the unit test I had here wasn't triggering the sql map code. Converting things to a kernel test. Let's see what happens.
Comment #18
heddnI was able to reproduce the issue locally on php 7.0. So I'm going to assume that the testbot will too. Here's the fix.
Comment #19
heddnAnd here's the whole thing with the tests.
Comment #20
catchShould we add a follow-up issue to move back to late static binding once we fully drop PHP 7.0 support? Otherwise looks good to me. Also bumping to major since this has actual side effects rather than just being a notice.
Comment #21
heddnOpened #3046932: Move back to late static binding in sql map.
Comment #22
catchThanks for opening the follow-up, I think this is ready to go.
Comment #23
alexpottIsn't this an API change? Since if you extend Sql you might be relying on the late static binding?
Comment #24
heddnIf you are depending on the late static binding, it would be a bug on PHP 7.0. I'm find with just letting this ride, but it is a bug and as long as we support PHP 7.0, migrations won't work on that version of PHP.
Comment #25
alexpottWe can preserve the late static binding by using
$this
instead. That way we keep the current behaviour but fortunately PHP7 is not broken in the same way. See https://stackoverflow.com/questions/24476194/difference-between-static-a...Comment #26
heddnThis seems a better/cleaner fix. Back to RTBC.
Comment #28
heddnComment #29
Les LimThanks! Verified both the bug and that the patch in #25 works.
Comment #31
alexpottUnrelated fail
Comment #33
alexpottMore js randomness
Comment #35
catch