Skip to content

Commit 3f5c118

Browse files
richard67wilsonge
authored andcommitted
Add trimQuery function definition
Add trimQuery function definition forgotten with my previous change
1 parent 176c6e7 commit 3f5c118

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

administrator/components/com_admin/script.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,4 +1842,35 @@ private function convertUtf8mb4QueryToUtf8($query)
18421842
// Replace utf8mb4 with utf8
18431843
return str_replace('utf8mb4', 'utf8', $query);
18441844
}
1845+
1846+
/**
1847+
* Trim comment and blank lines out of a query string
1848+
*
1849+
* @param string $query query string to be trimmed
1850+
*
1851+
* @return string String with leading comment lines removed
1852+
*
1853+
* @since 3.5
1854+
*/
1855+
private function trimQuery($query)
1856+
{
1857+
$query = trim($query);
1858+
1859+
while (substr($query, 0, 1) == '#' || substr($query, 0, 2) == '--' || substr($query, 0, 2) == '/*')
1860+
{
1861+
$endChars = (substr($query, 0, 1) == '#' || substr($query, 0, 2) == '--') ? "\n" : "*/";
1862+
1863+
if ($position = strpos($query, $endChars))
1864+
{
1865+
$query = trim(substr($query, $position + strlen($endChars)));
1866+
}
1867+
else
1868+
{
1869+
// If no newline, the rest of the file is a comment, so return an empty string.
1870+
return '';
1871+
}
1872+
}
1873+
1874+
return trim($query);
1875+
}
18451876
}

0 commit comments

Comments
 (0)