After the last update on 04/11/2016 the dd function is printing blank on dd() when we do it with migrate tools

I don't know why, but I go back the version and it works again. Any idea about it?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guilopes created an issue. See original summary.

guilopes’s picture

Priority: Normal » Major
willzyx’s picture

Recently dd() was modified in a couple of issues
#2559061: Fatal error: Cannot redeclare dd() - if the problem is related with this change make sure that there are not conflicts with other global function
#2191395: Make dpm() and friends pluggable (with Krumo, Kint, Ladybug etc) - we have introduced a pluggable dumper system which have replaced the old dd() implementation. Could be that this change causes the problem but I cannot reproduce it on my environment

@guilopes please can you indicate your devel configuration and the steps to reproduce the issue on a clean installation?

dom18fr’s picture

I experience the same trying to use dd function in a console context using drush. In such case, DevelDumperManager::hasAccessToDevelInformation() return false as it fail to retrieve any authenticated user. May be this can be solved by adding a test on cli context, something like :

<?php
/**
   * Checks whether a user has access to devel information.
   *
   * @return bool
   *   TRUE if the user has the permission, FALSE otherwise.
   */
  protected function hasAccessToDevelInformation() {

    if (PHP_SAPI === 'cli') {

      return TRUE;
    }

    return $this->account && $this->account->hasPermission('access devel information');
  }
?>
willzyx’s picture

@dom18fr probably your problem is not related to the access checking. As you can see dd() (alias for \Drupal\devel\DevelDumperManager::debug()) writes the dump in the debug file in any case and only when it fails to write in the file checks the permission for show a message

  /**
   * {@inheritdoc}
   */
  public function debug($input, $name = NULL, $plugin_id = NULL) {
    $name = $name ? $name . ': ' : '';
    $output = $this->export($input, $name, $plugin_id) . "\n";
    // The temp directory does vary across multiple simpletest instances.
    $file = file_directory_temp() . '/drupal_debug.txt';
    if (file_put_contents($file, $output, FILE_APPEND) === FALSE && $this->hasAccessToDevelInformation()) {
      drupal_set_message(t('Devel was unable to write to %file.', ['%file' => $file]), 'error');
      return FALSE;
    }
  }
willzyx’s picture

Status: Active » Postponed (maintainer needs more info)
dom18fr’s picture

@willzyx thanks for repliying,
Actually, the DevelDumperManager::export() perform an access check using DevelDumperManager::hasAccessToDevelInformation, and it fails so $output is empty, resulting in writing nothing in drupal_debug.txt nor printing anything in the console.
My approach may be wrong, but the code snippet i post do solve my problem.

willzyx’s picture

@dom18fr apologize for the previous answer, you are completely right :)
DevelDumperManager::debug() should not check for permission as was done in the previous drupal_debug() implementation. Added minimal test coverage for this

willzyx’s picture

Status: Postponed (maintainer needs more info) » Needs review
willzyx’s picture

Title: dd function is not working with migrate » dd function is not working for user without 'access devel information' permission

  • willzyx committed 5efd60d on 8.x-1.x
    Issue #2705897 by willzyx, guilopes: dd function is not working for user...
willzyx’s picture

Status: Needs review » Fixed

Committed and pushed to 8.x. Thanks!

guilopes’s picture

Thanks guys for the fast support and solving!

Status: Fixed » Closed (fixed)

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

guilopes’s picture