Skip to content
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

FIX Ensure source_file_comments works without throwing errors #5

Merged

Conversation

GuySartorelli
Copy link
Member

Base templates now include some regex to check the doctype, so the correct <base> tag can be used.

The code that checks for doctype in includeDebuggingComments() is (understandably) very naive and didn't account for the new regex. Now it does.

Issue

@@ -1309,8 +1309,8 @@ EOC;
{
// If this template contains a doctype, put it right after it,
// if not, put it after the <html> tag to avoid IE glitches
if (stripos($code ?? '', "<!doctype") !== false) {
$code = preg_replace('/(<!doctype[^>]*("[^"]")*[^>]*>)/im', "$1\r\n<!-- template $templateName -->", $code ?? '');
if (preg_match('/(?<!preg_match\(\'\/)<!doctype/i', $code)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? The string preg_match is here twice, once as a function call and once as part of the regex

If this is correct, please an inline comment to at least say that it's intentional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we're using preg_match to look for a match, and the match we're looking for must not be prepended with preg_match(. I'll add a comment about it

@GuySartorelli GuySartorelli force-pushed the pulls/1/sourcefile-comments branch from bf71f5a to d86fb1e Compare November 18, 2024 20:47
@emteknetnz emteknetnz merged commit 4276205 into silverstripe:1 Nov 18, 2024
7 checks passed
@emteknetnz emteknetnz deleted the pulls/1/sourcefile-comments branch November 18, 2024 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants