Skip to content

Commit eda00f8

Browse files
committed
Helpers::loadFromFile improved whitespace handling
1 parent 1490a9e commit eda00f8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Database/Helpers.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,21 @@ public static function loadFromFile(Connection $connection, $file): int
193193
$sql = '';
194194
$pdo = $connection->getPdo(); // native query without logging
195195
while (!feof($handle)) {
196-
$s = rtrim((string) fgets($handle));
196+
$s = (string) fgets($handle);
197197
if (!strncasecmp($s, 'DELIMITER ', 10)) {
198-
$delimiter = substr($s, 10);
198+
$delimiter = trim(substr($s, 10));
199199

200-
} elseif (substr($s, -strlen($delimiter)) === $delimiter) {
201-
$sql .= substr($s, 0, -strlen($delimiter));
200+
} elseif (substr($ts = rtrim($s), -strlen($delimiter)) === $delimiter) {
201+
$sql .= substr($ts, 0, -strlen($delimiter));
202202
$pdo->exec($sql);
203203
$sql = '';
204204
$count++;
205205

206206
} else {
207-
$sql .= $s . "\n";
207+
$sql .= $s;
208208
}
209209
}
210-
if (trim($sql) !== '') {
210+
if (rtrim($sql) !== '') {
211211
$pdo->exec($sql);
212212
$count++;
213213
}

0 commit comments

Comments
 (0)