#97844SqlReader-Class does not recognize multi line comments in a sql file
Description
Try the following:
- create a file ext_tables_static+adt.sql in the root of an extension
- it should be imported when the extension ist loaded the first time
- more information here: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/ExtTablesStaticAdtSql.html
It works when the file contains only the following comment styles:
# single line comment -- single line comment
It does not work with comment styles like this:
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; /*!40000 ALTER TABLE `tx_mytable` DISABLE KEYS */;
In this case every line after the first appearence of /* is dropped. The reason lies in these code:
sysext/core/Classes/Database/Schema/SqlReader.php, line 99 – 112:
// recognizes the beginning of a multiline comment
if (strpos($lineContent, '/*') === 0 && substr($lineContent, -2) !== '*/') {
$isInMultilineComment = true;
}
// should recognize the ending of a mulitline comment but doesn't because
// the */ is not on expected position -2. Perhaps it would be sufficent to ask
// if */ is anywhere in the line: strpos($lineContent, '*/') !== 0
if (substr($lineContent, -2) === '*/') {
$isInMultilineComment = false;
}
In my tries it was sufficient to change the line
(substr($lineContent, -2) === '*/') {
to
(strpos($lineContent, '*/') !== 0) {Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.