Commit f3f6b7dd authored by Steve Müller's avatar Steve Müller

Merge pull request #439 from jmontoyaa/patch-2

realpath return false when using the script in a phar file.
parents 8b28a9a1 e4cbc275
...@@ -65,20 +65,26 @@ EOT ...@@ -65,20 +65,26 @@ EOT
if (($fileNames = $input->getArgument('file')) !== null) { if (($fileNames = $input->getArgument('file')) !== null) {
foreach ((array) $fileNames as $fileName) { foreach ((array) $fileNames as $fileName) {
$fileName = realpath($fileName);
if ( ! file_exists($fileName)) { $filePath = realpath($fileName);
// Phar compatibility.
if (false === $filePath) {
$filePath = $fileName;
}
if ( ! file_exists($filePath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("SQL file '<info>%s</info>' does not exist.", $fileName) sprintf("SQL file '<info>%s</info>' does not exist.", $filePath)
); );
} else if ( ! is_readable($fileName)) { } else if ( ! is_readable($filePath)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf("SQL file '<info>%s</info>' does not have read permissions.", $fileName) sprintf("SQL file '<info>%s</info>' does not have read permissions.", $filePath)
); );
} }
$output->write(sprintf("Processing file '<info>%s</info>'... ", $fileName)); $output->write(sprintf("Processing file '<info>%s</info>'... ", $filePath));
$sql = file_get_contents($fileName); $sql = file_get_contents($filePath);
if ($conn instanceof \Doctrine\DBAL\Driver\PDOConnection) { if ($conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
// PDO Drivers // PDO Drivers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment