Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293850

MigrateExecutable should catch not only exceptions, but also fatal errors

$
0
0

Problem/Motivation

I discovered this while working on #3166602: Ensure media_filter → media_embed mapping does not cause fatal errors and subsequently #3166930: Migrated filters may have invalid/incomplete settings applied.

If a fatal PHP error occurs in the middle of a migration, it leaves the migration in a weird state:

  1. the message of the fatal error is not logged into the Migration system's messages tables, but only in the PHP error log and into watchdog
  2. the migration is left in the \Drupal\migrate\Plugin\MigrationInterface::STATUS_IMPORTING state
  3. therefore the migration is effectively "stuck", and you need to manually unstuck it

Steps to reproduce

See the STR in #3166930: Migrated filters may have invalid/incomplete settings applied.

Proposed resolution

Set a custom exception handler while in MigrateExecutable, because these are currently caught by _drupal_exception_handler(), so surely the migration system can do the same, but provide extra context?

  1. In PHP 7, fatal errors can be caught! So let's catch them, and treat them like exceptions. See https://www.php.net/manual/en/language.errors.php7.php→ see #2👀
  2. We currently only have
      /**
       * Migration error.
       */
      const MESSAGE_ERROR = 1;
    
      /**
       * Migration warning.
       */
      const MESSAGE_WARNING = 2;
    
      /**
       * Migration notice.
       */
      const MESSAGE_NOTICE = 3;
    
      /**
       * Migration info.
       */
      const MESSAGE_INFORMATIONAL = 4;
    

    Also add MESSAGE_FATAL_ERROR so that it's possible to communicate this is even worse than MESSAGE_ERROR. → see #3👀

Remaining tasks

  • Update issue summary (Novice).
  • Add tests.

User interface changes

Fatal errors also show up.

API changes

Addition: \Drupal\migrate\Plugin\MigrationInterface:MESSAGE_FATAL_ERROR.

Data model changes

None.

Release notes snippet

Fatal errors while running a migration no longer cause the migration system to crash.


Viewing all articles
Browse latest Browse all 293850


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>