Skip to content

Commit a5b0a19

Browse files
authored
Throw exception with advice to increase pcre.backtrack_limit
if preg_replace returned null during dump loading.
1 parent 0ff3582 commit a5b0a19

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Codeception/Module/Db.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ private function readSql($databaseKey = null, $databaseConfig = null): void
529529
}
530530

531531
/**
532-
* @throws ModuleConfigException
532+
* @throws ModuleConfigException|ModuleException
533533
*/
534534
private function readSqlFile(string $filePath): ?string
535535
{
@@ -545,7 +545,16 @@ private function readSqlFile(string $filePath): ?string
545545
$sql = file_get_contents(Configuration::projectDir() . $filePath);
546546

547547
// remove C-style comments (except MySQL directives)
548-
return preg_replace('#/\*(?!!\d+).*?\*/#s', '', $sql);
548+
$replaced = preg_replace('#/\*(?!!\d+).*?\*/#s', '', $sql);
549+
550+
if (!empty($sql) && is_null($replaced)) {
551+
throw new ModuleException(
552+
__CLASS__,
553+
"Please, increase pcre.backtrack_limit value in PHP CLI config"
554+
);
555+
}
556+
557+
return $replaced;
549558
}
550559

551560
private function connect($databaseKey, $databaseConfig): void

0 commit comments

Comments
 (0)