Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.6, 4.7
-
Fix Version/s: 4.7.13
-
Component/s: Core CiviCRM
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Contributed Code
Description
This function includes these lines:
//get rid of comments starting with # and -- $string = preg_replace("/^#[^\n]*$/m", "\n", $string); $string = preg_replace("/^(--[^-]).*/m", "\n", $string);
From my testing, it appears this causes the comment AND the next line to be stripped. As a result, this SQL fails, because the CREATE TABLE line is stripped and the query that's executed starts with `id` int(10) ... :
--
-- Do something.
--
CREATE TABLE IF NOT EXISTS `mytable` (
`id` int(10) unsigned NOT NULL
);
The workaround is to add a newline after the third comment, like so:
--
-- Do something.
--
CREATE TABLE IF NOT EXISTS `mytable` (
`id` int(10) unsigned NOT NULL
);
I think this is related to the /m regex modifier, but haven't yet got my head around what that modifier does.
Attachments
Issue Links
- links to