1

I have the following command callback function defined in my .drush.inc file:

function drush_bv_ftp_products() {
  echo $aadfadf;
  var_dump(error_get_last());
}

Assume hook_drush_command() is properly implemented and has an alias of 'abc'.

When I run drush site.local abc I get NULL for output. What I would expect to see is similar to:

Array
(
    [type] => 8
    [message] => Undefined variable: aadfadf
    [file] => ...
    [line] => ...
)

I'm running php 5.3.28 so error_get_last is there. Any thoughts from the Drush masters out there as to what could be going wrong here?

1

Drush sets an error handler via set_error_handler('drush_error_handler');. This interferes with the operation of error_get_last()`, as php resets the last error when the error handler is called; error_get_last() always returns NULL with an error handler, even if it is the first function called in the handler.

Since there is no way to disable the Drush error handler, this prevents the use of error_get_last() in Drush command files. For a quick test, you could always temporarily comment out the call to set_error_handler in Drush.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.