Skip to content

Commit

Permalink
Merge pull request #439 from jmontoyaa/patch-2
Browse files Browse the repository at this point in the history
realpath return false when using the script in a phar file.
  • Loading branch information
deeky666 committed Dec 6, 2013
2 parents 8b28a9a + e4cbc27 commit f3f6b7d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php
Expand Up @@ -65,20 +65,26 @@ protected function execute(InputInterface $input, OutputInterface $output)

if (($fileNames = $input->getArgument('file')) !== null) {
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(
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
Expand Down

0 comments on commit f3f6b7d

Please sign in to comment.