DDC-348: AbstractFileDriver: _findMappingFile - no Exception thrown if file doesnt exist #432

Closed
opened 2026-01-22 12:38:03 +01:00 by admin · 2 comments
Owner

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'");
}

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'"); }
admin added the Bug label 2026-01-22 12:38:03 +01:00
admin closed this issue 2026-01-22 12:38:04 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2010):

Comment created by romanb:

This is already fixed in trunk. Thanks!

@doctrinebot commented on GitHub (Feb 18, 2010): Comment created by romanb: This is already fixed in trunk. Thanks!
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Feb 18, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#432