Commit 1d578561 authored by ergonlogic's avatar ergonlogic

Split regexes into helper function with alter hook and static caching, and add docs for new hook.

parent f9094fde
......@@ -163,23 +163,36 @@ port=%s
return $descriptorspec;
}
function filter_line(&$line) {
$regexes = array(
// remove DEFINER entries
// XXX: this should be anchored at ^
// original sed regex: /\\*!50013 DEFINER=.*/d
'#/\\*!50013 DEFINER=.*/#' => FALSE,
// remove another kind of DEFINER line
// original sed regex: s|/\\*!50017 DEFINER=`[^`]*`@`[^`]*`\s*\\*/||g
// XXX: should also be anchored
// XXX: why the hell is there *another* DEFINER regex here?!
'#/\\*!50017 DEFINER=`[^`]*`@`[^`]*`\s*\\*/#' => '',
// remove broken CREATE ALGORITHM entries
// original sed regex: s|/\\*!50001 CREATE ALGORITHM=UNDEFINED \\*/|/\\*!50001 CREATE \\*/|g
// XXX: should also be anchored
'#/\\*!50001 CREATE ALGORITHM=UNDEFINED \\*/#' => '/\\*!50001 CREATE \\*/',
);
/**
* Return an array of regexes to filter lines of mysqldumps.
*/
function get_regexes() {
static $regexes = NULL;
if (is_null($regexes)) {
$regexes = array(
// remove DEFINER entries
// XXX: this should be anchored at ^
// original sed regex: /\\*!50013 DEFINER=.*/d
'#/\\*!50013 DEFINER=.*/#' => FALSE,
// remove another kind of DEFINER line
// original sed regex: s|/\\*!50017 DEFINER=`[^`]*`@`[^`]*`\s*\\*/||g
// XXX: should also be anchored
// XXX: why the hell is there *another* DEFINER regex here?!
'#/\\*!50017 DEFINER=`[^`]*`@`[^`]*`\s*\\*/#' => '',
// remove broken CREATE ALGORITHM entries
// original sed regex: s|/\\*!50001 CREATE ALGORITHM=UNDEFINED \\*/|/\\*!50001 CREATE \\*/|g
// XXX: should also be anchored
'#/\\*!50001 CREATE ALGORITHM=UNDEFINED \\*/#' => '/\\*!50001 CREATE \\*/',
);
// Allow regexes to be altered or appended to.
drush_command_invoke_all_ref('provision_mysql_regex_alter', $regexes);
}
return $regexes;
}
function filter_line(&$line) {
$regexes = $this->get_regexes();
foreach ($regexes as $find => $replace) {
if ($replace === FALSE) {
if (preg_match($find, $line)) {
......
......@@ -251,3 +251,14 @@ function hook_provision_drupal_chmod_not_recursive_directories_alter($chmod_not_
function hook_provision_drupal_install_settings_alter(&$settings, $url) {
$settings['forms']['install_configure_form']['update_status_module'] = array();
}
/**
* Alter the array of regexes used to filter mysqldumps.
*
* @param $regexes
* An array of patterns to match (keys) and replacement patterns (values).
* Setting a value to FALSE will omit the line entirely from the database
* dump.
*/
function hook_provision_mysql_regex_alter(&$regexes) {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment