Re: [SMARTY-DEV] DIR_SEP constant

From: Date: Sat, 29 Mar 2003 00:37:09 +0000
Subject: Re: [SMARTY-DEV] DIR_SEP constant
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1047@lists.php.net to get a copy of this message
On Thu, Mar 27, 2003 at 12:35:20PM -0800, boots wrote: > I was wondering if it would be possible to get the following tiny > change into Smarty.class.php: > > REPLACE: (line 50:) > define('DIR_SEP', DIRECTORY_SEPARATOR); > > WITH: (line 50:) > if (!defined('DIR_SEP')) > { > define('DIR_SEP', DIRECTORY_SEPARATOR); > } > > so that notices don't get thrown when other libraries have already > defined DIR_SEP. > > Thanks > > xo boots short: i think: no. use <?php @require 'Smarty.class.php'; ?> to suppress that notice. longer: you made me thinking about DIR_SEP. if we cannot define DIR_SEP in smarty we have to ensure that the "other libraries" defined DIR_SEP right. some of smarties file-handling-functions can react very sensitive of a false setting of DIR_SEP. to be fully surgically: i'm *really* sure you wouldn't want to try to set DIR_SEP to '../', require Smarty.class and call something like clear_all_cache() or another function that removes directories recursively. (for the records: i encourage *nobody* to test this, if he feels in doubt that he absolutely knows what he's doing) but i would also reject to add something like: if (!defined('DIR_SEP')) define('DIR_SEP', DIRECTORY_SEPARATOR); else if (DIR_SEP!=DIRECTORY_SEPARATOR) trigger_error('cannot define DIR_SEP', E_USER_ERROR) this would look a bit paranoid. i think DIR_SEP is a relict of times where DIRECTORY_SEPARATOR wasn't available in php natively. since smarty does not support php before 4.0.6 (where DIRECTORY_SEPARATOR was introduced), a cleaner solution would be to abandon DIR_SEP fully and only use DIRECTORY_SEPARATOR inside smarty. i don't see a reason against this, but this would have to be discussed with Monte. conclusion: if you need a fast solution: lower you error_reporting temporarily (while the inclusion of Smarty.class.php) or supress the notice with the @-operator. or maybe change the order of the libraries you include, then smarty is in charge of definig DIR_SEP, and the other libraries complain instead of smarty (not that serious :) have fun messju

« previous php.smarty.dev (#1047) next »