I see the following notice and warning after doing an advanced db backup:

Notice: Undefined index: fields in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of modules\contrib\backup_migrate\lib\backup_migrate_core\src\Config\ConfigurableTrait.php).
Warning: Invalid argument supplied for foreach() in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of modules\contrib\backup_migrate\lib\backup_migrate_core\src\Config\ConfigurableTrait.php).

Notes:
- did not have this problem with 4.0 release
- the quick backup does not show any error, only visible with advanced db backup

Comments

Pasqualle created an issue. See original summary.

TD44’s picture

After updating from 8.x-4.0 to 8.x-4.1 i see :
(only with advanced backup)

@Pasqualle, how did you fix it?


    Notice: Undefined index: fields in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of modules/contrib/backup_migrate/lib/backup_migrate_core/src/Config/ConfigurableTrait.php).

    BackupMigrate\Core\Plugin\PluginBase->configErrors(Array) (Line: 130)
    BackupMigrate\Core\Plugin\PluginManager->map('configErrors', Array) (Line: 90)
    Drupal\backup_migrate\Form\BackupMigrateAdvancedBackupForm->validateForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
    Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'backup_migrate_ui_manual_backup_advanced') (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm('backup_migrate_ui_manual_backup_advanced', Array, Object) (Line: 577)
    Drupal\Core\Form\FormBuilder->processForm('backup_migrate_ui_manual_backup_advanced', Array, Object) (Line: 320)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

    Warning: Invalid argument supplied for foreach() in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of modules/contrib/backup_migrate/lib/backup_migrate_core/src/Config/ConfigurableTrait.php).

    BackupMigrate\Core\Plugin\PluginBase->configErrors(Array) (Line: 130)
    BackupMigrate\Core\Plugin\PluginManager->map('configErrors', Array) (Line: 90)
    Drupal\backup_migrate\Form\BackupMigrateAdvancedBackupForm->validateForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 82)
    Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
    Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'backup_migrate_ui_manual_backup_advanced') (Line: 118)
    Drupal\Core\Form\FormValidator->validateForm('backup_migrate_ui_manual_backup_advanced', Array, Object) (Line: 577)
    Drupal\Core\Form\FormBuilder->processForm('backup_migrate_ui_manual_backup_advanced', Array, Object) (Line: 320)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 91)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 573)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 694)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Kabinfo’s picture

+1 for update for > 8.x-4.0 php.7.1

saweyer’s picture

after backup using 4.1 version, if I click on Settings, I see ERROR:
Warning: Invalid argument supplied for foreach() in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of modules/backup_migrate/lib/backup_migrate_core/src/Config/ConfigurableTrait.php).

it did download a .gzip file, but with the error, I'm not completely confident that the backup succeeded.

also, I'm seeing a WARNING:
Please install the Defuse PHP-encryption library via Composer to be able to encrypt backup files.

if I'm not going to encrypt backups, should I have to install this??

(no errors in B-and-M 4.0 version)

Steve

damienmckenna’s picture

@saweyer: Please open a new issue for that, it should do an 'information' message instead of a 'warning'.

godwing’s picture

Is there a solution to this issue?
This warning occurs if you are using Advanced Backup:

Warning: Invalid argument supplied for foreach() in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of /.../.../mysite.com/modules/backup_migrate/lib/backup_migrate_core/src/Config/ConfigurableTrait.php)

localnetwork’s picture

Having the same issue with @godwing when using advanced backup. Anyone here found a solution?

hoporr’s picture

Same issue: advanced backup throws this error. (fresh install: Core 8.9.6, PHP 7.2 )

I reverted to version 4.0, and it works fine again.

tonytheferg’s picture

Same here backing up from admin/config/development/backup_migrate/advanced.

Notice: Undefined index: fields in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of MY-SITE\web\modules\contrib\backup_migrate\lib\backup_migrate_core\src\Config\ConfigurableTrait.php)

Warning: Invalid argument supplied for foreach() in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of MY-SITE\web\modules\contrib\backup_migrate\lib\backup_migrate_core\src\Config\ConfigurableTrait.php)

Fresh install of 8.9.7 on php 7.3.15

couloir007’s picture

I've been seeing it for a long time. Uninstalling and reinstalling has not solved it.

Undefined index: fields in BackupMigrate\Core\Plugin\PluginBase->configErrors() (line 125 of modules/contrib/backup_migrate/lib/backup_migrate_core/src/Config/ConfigurableTrait.php).

tonytheferg’s picture

Putting lines 125-151 under a check to make sure the $schema is not empty removes the warning. if(!empty($schema)){

I am just tinkering around with a wild guess, and have no idea what trouble this might cause, so I didn't create a patch for this.

Maybe it will be a helpful clue for the right fix.

public function configErrors(array $params = []) {
  $out = [];

  // Do some basic validation based on length and regex matching.
  $schema = $this->configSchema($params);

 +//Check that the schema is not empty.
 +if(!empty($schema)){

    // Check each specified field.
    foreach ($schema['fields'] as $key => $field) {
      $value = $this->confGet($key);

      // Check if it's required.
      if (!empty($field['required']) && empty($value)) {
        $out[] = new ValidationError($key, $this->t('%title is required.'), ['%title' => $field['title']]);
      }

      // Check it for length.
      if (!empty($field['min_length']) && strlen($value) < $field['min_length']) {
        $out[] = new ValidationError($key, $this->t('%title must be at least %count characters.'), ['%title' => $field['title'], '%count' => $field['min_length']]);
      }
      if (!empty($field['max_length']) && strlen($value) > $field['max_length']) {
        $out[] = new ValidationError($key, $this->t('%title must be at no more than %count characters.'), ['%title' => $field['title'], '%count' => $field['max_length']]);
      }

      // Check for the regular expression match.
      if (!empty($field['must_match']) && !preg_match($field['must_match'], $value)) {
        if (!empty($field['must_match_error'])) {
          $out[] = new ValidationError($key, $field['must_match_error'], ['%title' => $field['title']]);
        }
        else {
          $out[] = new ValidationError($key, $this->t('%title contains invalid characters.'), ['%title' => $field['title']]);
        }
      }
    }
 +}
  return $out;
}
damienmckenna’s picture

That's really weird :-\ The question is - why is $schema empty?

tonytheferg’s picture

Right, I wondered that too, but I don't really know what is going on under the hood. If you think it's safe to add that check for now, I can post a patch... LMK

tonytheferg’s picture

Maybe because of this:

  /**
   * Get a default (blank) schema.
   *
   * @param array $params
   *   The parameters including:
   *    - operation - The operation being performed, will be one of:
   *      - 'backup': Configuration needed during a backup operation
   *      - 'restore': Configuration needed during a restore
   *      - 'initialize': Core configuration always needed by this item.
   *
   * @return array
   */
  public function configSchema(array $params = []) {
    return [];
  }

So maybe it's trying to check an empty array?

Or does * - 'backup': Configuration needed during a backup operation include advanced backups? That is where the notice and warning are being fired.

tonytheferg’s picture

StatusFileSize
new3.21 KB

Ok, so if someone wants to test this patch locally, that would be helpful.

All it does, is put lines 125-151 under a check to make sure the $schema is not empty
if(!empty($schema)){
before running the configErrors checks.

Doing this removes both the notice and the warning.

This seems like a harmless enough check, but please don't apply this patch to a production environment until the maintainer reviews and says it's ok.

tonytheferg’s picture

Status: Active » Needs review
larisse’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new228.72 KB
new70.93 KB

The patch #15 remove the following notice and warning after doing an advanced db backup.

damienmckenna’s picture

Thank you for the patch and the review. Could someone please clean up the patch to make the Drupal coding standards? Thank you.

hmendes’s picture

Hi @DamienMcKenna,
The Drupal coding standards that you are saying would be to get the phpcs errors fixed for the entire ConfigurableTrait.php file?

damienmckenna’s picture

I'm mainly concerned about the two new lines added for the if() statement.

tonytheferg’s picture

@damien, sure. All I saw was that if(!empty($schema)){ was missing a space before the {

if(!empty($schema)) {
Anything else?

tonytheferg’s picture

StatusFileSize
new3.21 KB
hmendes’s picture

StatusFileSize
new17.83 KB
new3.21 KB

Accordingly to phpcs, there should be spaces after 'if', '\\' and ')'. phpcs_error.png
Adding a new patch.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #3102502: Plan for Backup and Migrate 8.x-4.2

Thank you hmendes, that's exactly what I was thinking of.

Committed. Thank you all for collaborating on this.

tonytheferg’s picture

ah, thanks!

Status: Fixed » Closed (fixed)

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