Problem/Motivation
We are developing on windows and due to the default setting of git's core.autocrlf = true
setting all line endings are handled by git.
This comes from GitLab's overall suggestion to setting up like this.
composer will checkout with git's cli if you are using dev-master
version constraint.
So if you are using drush to make the database updates on windows with cygwin the table output is printed a little bit slipped.
First I thought it is related to drush, but moshe showed me the right code base where it happens. Thanks for this!
https://github.com/drupal/drupal/blob/9.2.x/core/includes/update.inc#L40...
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module . '_update_' . $update);
$patterns = [
'/^\s*[\/*]*/',
'/(\n\s*\**)(.*)/',
'/\/$/',
'/^\s*/',
];
$replacements = ['', '$2', '', ''];
$description = preg_replace($patterns, $replacements, $func->getDocComment());
$ret[$module]['pending'][$update] = "$update - $description";
I think we could easily fix that by normalizing the line endings before extracting the description text.
// The description for an update comes from its Doxygen.
$func = new ReflectionFunction($module . '_update_' . $update);
$patterns = [
'/^\s*[\/*]*/',
'/(\n\s*\**)(.*)/',
'/\/$/',
'/^\s*/',
];
$replacements = ['', '$2', '', ''];
$description = preg_replace('/\r\n|\r/', "\n", $func->getDocComment());
$description = preg_replace($patterns, $replacements, $description);
$ret[$module]['pending'][$update] = "$update - $description";
What do you think?
Steps to reproduce
Requirement: The doc comment of the hook_update_N
or other update type has to have crlf
line endings
drush updb -y
Proposed resolution
Normalize line endings via another preg_replace()
in update_get_update_list()
Found that solution on TestDiscovery in Core: https://github.com/drupal/drupal/blob/9.2.x/core/lib/Drupal/Core/Test/Te...
Remaining tasks
User interface changes
Improved CLI table output via drush
I can elaborate on this with a merge request if you want.