Book Image

Drush for Developers - Second Edition

By : Juan Pablo Novillo Requena, Juan P Novillo Requena
Book Image

Drush for Developers - Second Edition

By: Juan Pablo Novillo Requena, Juan P Novillo Requena

Overview of this book

Table of Contents (13 chapters)
Drush for Developers Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Keeping Database Configuration and Code Together
Index

Rolling back when an error happens


When drush_set_error() is called during a command execution, the rollback mechanism jumps into action. The rollback mechanism gives us a chance to exit gracefully if something goes wrong. It is especially useful when we only want to perform a final action if a command is completed successfully. Drush itself uses the rollback mechanism when dealing with core and module upgrades, performing actions such as restoring original files back in place, and deleting the downloaded files of the new version if there is an error.

Here is the full sequence of invocations for a given command. In the following list, hook is the filename where the Drush command is implemented (excluding the .drush.inc extension) and COMMAND is the actual command name:

# 1.  hook_drush_init()
# 2.  drush_COMMAND_init()
# 3.  drush_hook_COMMAND_pre_validate()
# 4.  drush_hook_COMMAND_validate()
# 5.  drush_hook_pre_COMMAND()
# 6.  drush_hook_COMMAND()
# 7.  drush_hook_post_COMMAND()
# 8. hook_drush_exit...