-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TemplateProcessor cloneBlock wrongly clones images #1763
TemplateProcessor cloneBlock wrongly clones images #1763
Conversation
… part after the #number and fixing Process call to array instead of string
@@ -1085,7 +1085,7 @@ protected function indexClonedVariables($count, $xmlBlock) | |||
{ | |||
$results = array(); | |||
for ($i = 1; $i <= $count; $i++) { | |||
$results[] = preg_replace('/\$\{(.*?)\}/', '\${\\1#' . $i . '}', $xmlBlock); | |||
$results[] = preg_replace('/\$\{([^:]*?)(:.*?)?\}/', '\${\1#' . $i . '\2}', $xmlBlock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering why you're only using one \
compared to the old regex and to my changes in #1829:
$results[] = preg_replace('/\$\{(.*?)(:([^}])*)?\}/', '\${\\1#' . $i . '\\2}', $xmlBlock);
I'm not that much into this regex at the moment, so I don't know how they differ.
btw, this pr will also fix #1624
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Amerlander that's because in a single quoted string you don't have to double the
https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for explanation and for the merge! :)
Description
I was met with the issue reported in #1750 and fixed it.
The problem was that the regexp to clone and add number did include the size attributes in the tag before the number. So I added a second capture group so that image attributes are properly placed after the tag with it's added number.
I also fixed the call to Process to use an array as it otherwise cause hundred of errors as it now expects an array instead of a string.
All tests are passed and code coverage is unchanged.
Fixes #1750 #1624
Checklist:
composer run-script check --timeout=0
and no errors were reported