cvs: pear /Text_Wiki/Text Wiki.php

From: Date: Thu, 02 Mar 2006 01:55:27 +0000
Subject: cvs: pear /Text_Wiki/Text Wiki.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-38829@lists.php.net to get a copy of this message
justinpatrin Thu Mar 2 01:55:27 2006 UTC Modified files: /pear/Text_Wiki/Text Wiki.php Log: Alter factory to check to make sure the file is readable before including it http://cvs.php.net/viewcvs.cgi/pear/Text_Wiki/Text/Wiki.php?r1=1.42&r2=1.43&diff_format=u Index: pear/Text_Wiki/Text/Wiki.php diff -u pear/Text_Wiki/Text/Wiki.php:1.42 pear/Text_Wiki/Text/Wiki.php:1.43 --- pear/Text_Wiki/Text/Wiki.php:1.42 Wed Mar 1 16:58:17 2006 +++ pear/Text_Wiki/Text/Wiki.php Thu Mar 2 01:55:27 2006 @@ -9,7 +9,7 @@ * @package Text_Wiki * @author Paul M. Jones <pmjones@php.net> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 - * @version CVS: $Id: Wiki.php,v 1.42 2006/03/01 16:58:17 justinpatrin Exp $ + * @version CVS: $Id: Wiki.php,v 1.43 2006/03/02 01:55:27 justinpatrin Exp $ * @link http://pear.php.net/package/Text_Wiki */ @@ -430,21 +430,27 @@ function &factory($parser = 'Default', $rules = null) { $class = 'Text_Wiki_' . $parser; - $file = str_replace('_', '/', $class) . '.php'; - if (class_exists($class)) { - $obj =& new $class($rules); - return $obj; - } - if (include_once $file) { - if (class_exists($class)) { - $obj =& new $class($rules); - return $obj; - } else { + $file = str_replace('_', '/', $class).'.php'; + if (!class_exists($class)) { + $exists = false; + foreach (split(PATH_SEPARATOR, get_include_path()) as $path) { + if (file_exists($path.'/'.$file) + && is_readable($path.'/'.$file)) { + $exists = true; + break; + } + } + if (!$exists) { + return PEAR::raiseError('Could not find file '.$file.' in include_path'); + } + include_once($file); + if (!class_exists($class)) { return PEAR::raiseError('Class '.$class.' does not exist after including '.$file); } - } else { - return PEAR::raiseError('Could not include '.$file); } + + $obj =& new $class($rules); + return $obj; } /**

« previous php.pear.cvs (#38829) next »