[dev] Questions about MIME_Viewer

Brent J. Nordquist bjn at horde.org
Tue Jan 7 08:12:00 PST 2003


In the course of getting Orator up and going on my system, I found that
the oscon2001-case_study presentation tries to use a GIF image, but it's
not rendering on my system.  I saw some MIME_Viewer errors, and after
delving into it a bit I ended up with some questions.

(1)  In horde/lib/MIME/Viewer.php line 93:

	MIME_Viewer::includeDriver calls _getDriver, and then uses two
values from $ob -- however, _getDriver can legally return false (as
opposed to an object) as documented in the comment above _getDriver.
Shouldn't there be a check here that will prevent the call to
resolveDriver if $ob is false?  (I found it strange that the call
$ob->driver isn't producing a "not an object" error or something.)  But at
any rate, resolveDriver produces a nonsensical path when its arguments are
empty ("/lib/MIME/Viewer/.php") and then you get a file-not-found error on
include later on.

(2)  The way Orator is currently set up, and from comments like the
following in horde's MIME_Viewer, I am inferring that Horde apps are
allowed to use Horde's MIME viewer classes:

    /* Figure the correct driver for this MIME type. If there is no
       application-specific module, a general Horde one will attempt to
       be used. */

The problem is, I can't see how this could work as the code is now.  The
calling chain:

    MIME_Viewer::factory($mime_part, $mime_type)
        MIME_Viewer::includeDriver($mime_type)
            MIME_Viewer::_getDriver($mime_type, $registry->getApp())

(note how _getDriver is always called with the current app. -- in my case,
'orator')

_getDriver bails out early if there isn't a mime_drivers map for the
application (which there isn't in Orator currently):

    /* If the module doesn't exist in $mime_drivers_map, return now. */
    if (!array_key_exists($module, $mime_drivers_map)) {
        return false;
    }

I can't see that it will ever check with $module = 'horde' (as the comment
up above about a "general Horde one" implies).  Am I missing something?
I started to just add orator/config/mime_drivers.php but that seems to
expect orator/lib/MIME/Viewer/* to exist, so then it wouldn't be sharing
Horde's viewer code.  If Orator needs its own versions, I'll start working
on it.

Thanks!

-- 
Brent J. Nordquist <bjn at horde.org> N0BJN
Other contact information: http://www.nordist.net/contact.html



More information about the dev mailing list