Commit e4cbc275 authored by Julio Montoya's avatar Julio Montoya

Fixing realpath issue when using command in a phar

Applying suggestions.
parent 52763253
......@@ -65,18 +65,26 @@ EOT
if (($fileNames = $input->getArgument('file')) !== null) {
foreach ((array) $fileNames as $fileName) {
if (!file_exists($fileName)) {
$filePath = realpath($fileName);
// Phar compatibility.
if (false === $filePath) {
$filePath = $fileName;
}
if ( ! file_exists($filePath)) {
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(
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));
$sql = file_get_contents($fileName);
$output->write(sprintf("Processing file '<info>%s</info>'... ", $filePath));
$sql = file_get_contents($filePath);
if ($conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
// 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