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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jian he created an issue. See original summary.

jian he’s picture

Title: Undefined class constant 'SOURCE_IDS_HASH' » Undefined class constant 'SOURCE_IDS_HASH'. 8.6.x does not have this issue.
Issue summary: View changes
jian he’s picture

Title: Undefined class constant 'SOURCE_IDS_HASH'. 8.6.x does not have this issue. » PHP 7.0 got error: Undefined class constant 'SOURCE_IDS_HASH'
Issue summary: View changes
jian he’s picture

Status: Active » Needs review
FileSize
885 bytes

Got it at last.
Change static::SOURCE_IDS_HASH to self::SOURCE_IDS_HASH will solve this issue.

jian he’s picture

There has similar error on line 663:

Error: Undefined class constant 'SOURCE_IDS_HASH' in Drupal\migrate\Plugin\migrate\id_map\Sql->saveMessage() (line 663 of /var/www/html/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php).

Doing the same change will solve it.

jian he’s picture

FileSize
1.28 KB
712 bytes

Fix #5

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

grahamC’s picture

I'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 the deleteDestination() 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:: for self:: would mean that subclasses can no longer override that constant...

heddn’s picture

Status: Needs review » Needs work

Any chance for a test? NW for tests.

heddn’s picture

heddn’s picture

heddn’s picture

#11 is just a re-post of #6 so it is last on the list.

heddn’s picture

Status: Needs review » Needs work

Hmm, 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.

heddn’s picture

catch’s picture

Priority: Normal » Major
heddn’s picture

Priority: Major » Normal

Those 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.

heddn’s picture

The 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.

heddn’s picture

I 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.

heddn’s picture

FileSize
8.42 KB

And here's the whole thing with the tests.

catch’s picture

Priority: Normal » Major

Should 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.

heddn’s picture

catch’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for opening the follow-up, I think this is ready to go.

alexpott’s picture

Isn't this an API change? Since if you extend Sql you might be relying on the late static binding?

heddn’s picture

If 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.

alexpott’s picture

We 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...

heddn’s picture

Status: Needs review » Reviewed & tested by the community

This seems a better/cleaner fix. Back to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: 3034599-25.patch, failed testing. View results

heddn’s picture

Status: Needs work » Reviewed & tested by the community
Les Lim’s picture

Thanks! Verified both the bug and that the patch in #25 works.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: 3034599-25.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated fail

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 25: 3034599-25.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

More js randomness

  • catch committed 0d00904 on 8.8.x
    Issue #3034599 by heddn, jian he, alexpott: PHP 7.0 got error: Undefined...
catch’s picture

Version: 8.8.x-dev » 8.7.x-dev
Status: Reviewed & tested by the community » Fixed

  • catch committed 82025eb on 8.7.x
    Issue #3034599 by heddn, jian he, alexpott: PHP 7.0 got error: Undefined...

Status: Fixed » Closed (fixed)

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