[Solar-talk] Error with Solar 0.28 and Text_Wiki 0.1.0

Paul M Jones pmjones at ciaweb.net
Sun Aug 26 17:22:10 CDT 2007


On Aug 26, 2007, at 10:08 AM, Andreas Ravnestad wrote:

> Paul M Jones wrote:
>> On Aug 26, 2007, at 9:52 AM, Andreas Ravnestad wrote:
>>
>>> Rodrigo Moraes wrote:
>>>> On 8/22/07, Andreas Ravnestad wrote:
>>>>
>>>>> Now, Solar is looking for a file "Text\Wiki\Parse 
>>>>> \Prefilter.php" which
>>>>> doesn't exist. However, there is a class named
>>>>> Text_Wiki_Parse_Prefilter, but it resides in
>>>>> "Text\Wiki\Parse\Default\Prefilter.php" (difference being the  
>>>>> Default
>>>>> folder). As far as I can tell, this used to work with Solar  
>>>>> 0.27. Any
>>>>> ideas how to fix?
>>>>>
>>>
>>> This problem is still persistent and is plaguing one of my  
>>> production servers. I currently must choose between downgrading  
>>> to solar 0.27 (and rolling back *alot* of code), and displaying  
>>> flat wiki text (no formatting). Paul, it would be really nice if  
>>> you could take a look at this --  I will be very happy to help  
>>> out in any way I can!
>>
>> Will do so today -- need to install Text_Wiki and the MediaWiki  
>> parse/render set, yes?
>>
>
> Great! Yes, those are the packages I am using :) You are likely to  
> see that a test case will work fine in "vanilla" PHP (no Solar),  
> but will fail with the error detailed earlier when running a test  
> case on top of Solar.

Test code is this:

     <?php
     error_reporting(E_ALL|E_STRICT);
     ini_set('display_errors', true);
     set_include_path('/path/to/pear');

     // include 'Solar.php';

     include 'Text/Wiki/Mediawiki.php';

     $wiki = new Text_Wiki_Mediawiki();
     $text = "\n== Title ==\n\nHi there!\n";
     $html = $wiki->transform($text);

     var_dump($html);

It works (albeit with lots of E_STRICT notices) when you set the path  
to PEAR and leave the Solar include line commented out.  The text is  
converted to HTML with H2 and a paragraph markup.


The Problem
-----------

The code fails when you un-comment the Solar include line, throwing  
this exception:

     Fatal error: Uncaught exception 'Solar_Exception_FileNotReadable'
     class::code 'Solar::ERR_FILE_NOT_READABLE'
     with message 'File does not exist or is not readable'
     information array (
       'file' => 'Text/Wiki/Parse/Prefilter.php',
     )
     Stack trace:
       #0 /Users/pmjones/Sites/dev/solar/trunk/Solar.php(895):
          Solar::factory('Solar_Exception...', Array)
       #1 /Users/pmjones/Sites/dev/solar/trunk/Solar.php(481):
          Solar::exception('Solar', 'ERR_FILE_NOT_RE...', 'File does  
not e...', Array)
       #2 /Users/pmjones/Sites/dev/solar/trunk/Solar.php(397):
          Solar::run('Text/Wiki/Parse...')
       #3 [internal function]: Solar::loadClass('Text_Wiki_Parse...')
       #4 [internal function]: spl_autoload_call('Text_Wiki_Parse...')
       #5 /Users/pmjones/pear/php/Text/Wiki.php(1317): class_exists 
('Text_Wiki_Parse...')
       #6 /Users/pmjones/pear/php/Text/Wiki.php(952): Text_Wiki- 
 >loadParseObj('Prefilter')
       #7 /Users/pmjones/pear/php/Text/Wiki.php(917): Text_Wiki->parse 
('?== Title ==??H...')
       #8 /Users/pmjones/Sites/pmjones.dnsalias.net/test/test-wiki.php 
(11):
          Te in /Users/pmjones/Sites/dev/solar/trunk/Solar.php on  
line 605

So the problem is with class_exists($class) in Text/Wiki.php on line  
1317.  As noted earlier, it is related to spl_autoload().


The Fix
-------

Change line 1317 to "class_exists($class, false)" ... the second  
"false" param tells it not to use autoload.  Do that, and the test  
code works, so it should work on your production machines as well.

FYI, the full list of class_exists() calls for the whole Text_Wiki  
project is (line numbers) 472, 474, 1317, 1354, 1388, 1526.  These  
other lines did not cause exceptions, but they might in the future,  
so you may want to apply the "false" param fix on them as well.

I will continue researching a bit and see why it's not finding the  
Prefilter rule.

Hope this helps, please let me know if it does not.


--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.  <http://solarphp.com>

Join the Solar community wiki!  <http://solarphp.org>

Savant: The simple, elegant, and powerful solution for
templates in PHP.  <http://phpsavant.com>




More information about the Solar-talk mailing list