Bug Report #3045

Userguide unusable if class not found

Added by Kyle Treubig over 1 year ago. Updated over 1 year ago.

Status:Closed Start date:07/02/2010
Priority:Normal Due date:
Assignee:Woody Gilk % Done:

0%

Category:Modules:Userguide
Target version:v3.0.7
Resolution:fixed Points:

Description

If any class in one's Kohana setup extends a class that does not exist in the current setup, the userguide API browser encounters a class not found exception and the API browser is inaccessible. This happens for any page of the API browser.

For example, a module with drivers for different ORMs,

class Model_A1_User_Sprig extends Sprig { }
class Model_A1_User_Mango extends Mango { }

If the Mango or Sprig modules are not enabled, the userguide API browser throws an exception.

It should handle this gracefully so as to still allow access to the rest of the API browser.

0001-Added-userguide-auto-loader-to-create-stub-classes-f.patch (1.7 kB) Kyle Treubig, 07/07/2010 10:34 am

Associated revisions

Revision 020bc4dc
Added by Woody Gilk over 1 year ago

Added Kodoc_Missing and Kodoc_Missing::create_class, used as an autoloader to create classes that do not exist, fixes #3045

History

Updated by Woody Gilk over 1 year ago

  • Status changed from New to Feedback
  • Target version set to v3.0.7

Patches welcome!

Updated by Kyle Treubig over 1 year ago

I'll try to take a look at it over the weekend and work on a patch.

Updated by Kyle Treubig over 1 year ago

This is a tricky issue. The error occurs as a fatal error when the file is included through the auto-loader (and subsequently, the class file gets interpreted). There doesn't seem to be an easy way to catch this kind of error (fatal error, class not found).

The "correct" solution (in my opinion) is that the class developer should check for the optional, external dependency (in the case of a driver scenario like the A1 user model):

if (Kohana::find_file('classes', 'Mango'))
{
class Model_A1_User_Mango extends Mango { }
}

Still doesn't seem right that a "3rd party module" can completely break the userguide...

[Edit] class_exists wouldn't work if the class did exist in the current application, but hadn't been loaded yet. Updated example to use find_file.

Updated by Matt Button over 1 year ago

Surely the "easiest" way to avoid this error would be to add a second autoloader which just declares stubs for classes that don't exist?

Updated by Woody Gilk over 1 year ago

That is an interesting idea, Matt. There really is no harm in setting up an autoloader that creates classes to prevent fatal errors in the API browser.

Updated by Kyle Treubig over 1 year ago

Here's a patch for the stub class autoloader.

Updated by Woody Gilk over 1 year ago

  • Status changed from Feedback to Closed
  • Resolution set to fixed

Also available in: Atom PDF