Stop JTable from giving up too early #1846

Closed
wants to merge 1 commit into
from
Jump to file
+8 −11
Split
@@ -218,22 +218,19 @@ public static function getInstance($type, $prefix = 'JTable', $config = array())
if (!class_exists($tableClass))
{
// Search for the class file in the JTable include paths.
- $path = JPath::find(self::addIncludePath(), strtolower($type) . '.php');
+ jimport('joomla.filesystem.path');
- if ($path)
+ $paths = JTable::addIncludePath();
+ $pathIndex = 0;
+ while (!class_exists($tableClass) && $pathIndex < count($paths))
{
- // Import the class file.
- include_once $path;
-
- // If we were unable to load the proper class, raise a warning and return false.
- if (!class_exists($tableClass))
+ if ($tryThis = JPath::find($paths[$pathIndex++], strtolower($type) . '.php'))
{
- JLog::add(JText::sprintf('JLIB_DATABASE_ERROR_CLASS_NOT_FOUND_IN_FILE', $tableClass), JLog::WARNING, 'jerror');
-
- return false;
+ // Import the class file.
+ include_once $tryThis;
}
}
- else
+ if (!class_exists($tableClass))
{
// If we were unable to find the class file in the JTable include paths, raise a warning and return false.
JLog::add(JText::sprintf('JLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND', $type), JLog::WARNING, 'jerror');