Loading bs_base.bs_base.install +24 −0 Original line number Diff line number Diff line Loading @@ -118,3 +118,27 @@ function bs_base_bs_update_8005($target_theme_name) { ]); } } /** * Check and fix bad update of bs_bootstrap to version 4.6.0. */ function bs_base_bs_update_8006($target_theme_name) { // Detect if target theme is updated to non-existent 'bs_bootstrap: 8005' // while actual bootstrap version used is 4.3.1. $themes_info = _bs_base_drupal_theme_list_info(); if (isset($themes_info[$target_theme_name])) { $yml_content = file_get_contents($themes_info[$target_theme_name]->pathname); if ($yml_content && (strpos($yml_content, 'bs_bootstrap: 8004') || strpos($yml_content, 'bs_bootstrap: 8005'))) { $package_content = file_get_contents($themes_info[$target_theme_name]->subpath . '/package.json'); if ($package_content && strpos($package_content, '"bootstrap": "~4.3.1",')) { // Fix update version info. $yml_content = str_replace('bs_bootstrap: 8004', 'bs_bootstrap: 8003', $yml_content); $yml_content = str_replace('bs_bootstrap: 8005', 'bs_bootstrap: 8003', $yml_content); file_put_contents($themes_info[$target_theme_name]->pathname, $yml_content); // Notify user that he needs to execute update one more time. drush_log("Bad update is fixed, please run `drush bs-tu $target_theme_name` one more time to update theme correctly.", \Drush\Log\LogLevel::ALERT); } } } } bs_base.drush.inc +2 −2 Original line number Diff line number Diff line Loading @@ -1504,11 +1504,11 @@ function _bs_base_set_yml_value($path, array $values, $add = FALSE) { // Regular expression pattern that can locate and change value based on yaml // array keys. $pattern = "#" . implode(":\n(?:.|\n)*?", explode('.', $yml_key)) . ":\s(.*?)\n#"; $pattern = "#" . implode(":\n(.|\n)*?(", explode('.', $yml_key)) . ":\s)(.*?)\n#"; $count = 0; $res = preg_replace_callback($pattern, function ($matches) use ($value) { return str_replace($matches[1], $value, $matches[0]); return str_replace($matches[2] . $matches[3], $matches[2] . $value, $matches[0]); }, $file_contents, 1, $count); // If variable does not exist and $add flag is turn on we will add this Loading Loading
bs_base.bs_base.install +24 −0 Original line number Diff line number Diff line Loading @@ -118,3 +118,27 @@ function bs_base_bs_update_8005($target_theme_name) { ]); } } /** * Check and fix bad update of bs_bootstrap to version 4.6.0. */ function bs_base_bs_update_8006($target_theme_name) { // Detect if target theme is updated to non-existent 'bs_bootstrap: 8005' // while actual bootstrap version used is 4.3.1. $themes_info = _bs_base_drupal_theme_list_info(); if (isset($themes_info[$target_theme_name])) { $yml_content = file_get_contents($themes_info[$target_theme_name]->pathname); if ($yml_content && (strpos($yml_content, 'bs_bootstrap: 8004') || strpos($yml_content, 'bs_bootstrap: 8005'))) { $package_content = file_get_contents($themes_info[$target_theme_name]->subpath . '/package.json'); if ($package_content && strpos($package_content, '"bootstrap": "~4.3.1",')) { // Fix update version info. $yml_content = str_replace('bs_bootstrap: 8004', 'bs_bootstrap: 8003', $yml_content); $yml_content = str_replace('bs_bootstrap: 8005', 'bs_bootstrap: 8003', $yml_content); file_put_contents($themes_info[$target_theme_name]->pathname, $yml_content); // Notify user that he needs to execute update one more time. drush_log("Bad update is fixed, please run `drush bs-tu $target_theme_name` one more time to update theme correctly.", \Drush\Log\LogLevel::ALERT); } } } }
bs_base.drush.inc +2 −2 Original line number Diff line number Diff line Loading @@ -1504,11 +1504,11 @@ function _bs_base_set_yml_value($path, array $values, $add = FALSE) { // Regular expression pattern that can locate and change value based on yaml // array keys. $pattern = "#" . implode(":\n(?:.|\n)*?", explode('.', $yml_key)) . ":\s(.*?)\n#"; $pattern = "#" . implode(":\n(.|\n)*?(", explode('.', $yml_key)) . ":\s)(.*?)\n#"; $count = 0; $res = preg_replace_callback($pattern, function ($matches) use ($value) { return str_replace($matches[1], $value, $matches[0]); return str_replace($matches[2] . $matches[3], $matches[2] . $value, $matches[0]); }, $file_contents, 1, $count); // If variable does not exist and $add flag is turn on we will add this Loading