When using this module in an install profile I get the following error:

Warning: array_merge(): Argument #2 is not an array in drupal_check_profile() (line 1188 of [...]/includes/install.inc).

This is because phpwkhtmltopdf_requirements() returns nothing (NULL) for any other phase than runtime.

hook_requirements currently looks like this:

/**
 * Implements hook_requirements().
 */
function phpwkhtmltopdf_requirements($phase) {
  // We only care to run our requirements validation on the "runtime" phase.
  switch ($phase) {
    case 'runtime':
      $results = array();

      module_load_include('module', 'phpwkhtmltopdf');
      // Get our own libraries to loop over and verify.
      $libraries = phpwkhtmltopdf_libraries_info();
      // Loop over the libraries this module defines and need to be verified.
      foreach($libraries as $name => $details) {
        $lib_results = phpwkhtmltopdf_requirements_validate_library($name, 'phpwkhtmltopdf_failed_generic');
        // Merge the results of this library with the previous results, we'll be returned all of them at the end.
        $results = array_merge($results, $lib_results);
      }
      // Return the validation results to Drupal.
      return $results;
      break;
  }
}

but should look like this:

/**
 * Implements hook_requirements().
 */
function phpwkhtmltopdf_requirements($phase) {
  // We only care to run our requirements validation on the "runtime" phase.
  switch ($phase) {
    case 'runtime':
      $results = array();

      module_load_include('module', 'phpwkhtmltopdf');
      // Get our own libraries to loop over and verify.
      $libraries = phpwkhtmltopdf_libraries_info();
      // Loop over the libraries this module defines and need to be verified.
      foreach($libraries as $name => $details) {
        $lib_results = phpwkhtmltopdf_requirements_validate_library($name, 'phpwkhtmltopdf_failed_generic');
        // Merge the results of this library with the previous results, we'll be returned all of them at the end.
        $results = array_merge($results, $lib_results);
      }
      // Return the validation results to Drupal.
      return $results;
      break;
  }
  return array();
}
CommentFileSizeAuthor
#3 i2486555-3.patch793 bytesattiks

Comments

jelle_s’s picture

Issue summary: View changes
cravecode’s picture

Thanks @Jelle_S, I'll get that updated.

attiks’s picture

Status: Active » Needs review
StatusFileSize
new793 bytes

Patch

  • cravecode committed 50e93c2 on 7.x-2.x authored by attiks
    Issue #2486555 by attiks: Hook requirements should return an empty array...
cravecode’s picture

Status: Needs review » Closed (fixed)

Thanks for the patch @attiks. You have perfect timing.
The patch is in 2.x-dev and a new release 7.x-2.1 (waiting on the release to propagate).