mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-348: AbstractFileDriver: _findMappingFile - no Exception thrown if file doesnt exist #431
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Feb 18, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user mariomaik:
There is a small bug in the _findMappingFile function in File: Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php
line:154
No Exception is thrown when the file couldnt be found.
$fileName is always set to the path which should be checked. so even if the file isnt found, $fileName is not null -> no exception is thrown.
CURRENT FUNCTION:
$fileName = null;
foreach ((array)$this->_paths as $path) {
$fileName = $path . DIRECTORY_SEPARATOR . str_replace('','.', $className) . $this->_fileExtension;
if (file_exists($fileName)) {
break;
}
}
if ($fileName === null) {
throw MappingException::mappingFileNotFound($className);
}
FIX: add a $tmpFileName
$fileName = null;
foreach ((array)$this->_paths as $path) {
$tmpFileName = $path . DIRECTORY_SEPARATOR . str_replace('', '.', $className) . $this->_fileExtension;
if (file_exists($tmpFileName)) {
$fileName = $tmpFileName;
break;
}
}
if ($fileName === null) {
throw MappingException::mappingFileNotFound($className);
}
Also the MappingException::mappingFileNotFound($className); function doesnt exist.
should be added in:
Doctrine/ORM/Mapping/MappingException.php
public static function mappingFileNotFound($className)
{
return new self("No mapping file found for class '$className'");
}