[pLog-svn] r5348 - in plog/branches/lifetype-1.2: . class class/action class/action/admin class/cache class/config class/controller class/dao class/dao/userdata class/data class/data/Date class/locale class/logger/config class/mail/phpmailer class/misc class/net/http class/net/http/phpsniff class/net/xmlrpc class/object class/plugin class/security class/summary/action class/summary/net class/template class/template/smarty/plugins class/test/helpers class/test/tests/dao class/test/tests/ui class/view class/view/admin class/xml/tree plugins/badbehavior

Jon Daley plogworld at jon.limedaley.com
Thu Apr 26 18:40:41 EDT 2007


I removed almost all require, require_once, include and include_once calls 
in our code.

There are some places in smarty, phpunit tests, and the getid stuff that I 
wasn't sure how it was working, so I am not sure if will be broken by this 
change.  If you get an error - simply replace the include with an 
include_once in class/object/loader.class.php and let me know about it, 
and I will investigate.


There are a couple places where it is appropriate to call include()

like in:
On Thu, 26 Apr 2007, jondaley at devel.lifetype.net wrote:
Modified: plog/branches/lifetype-1.2/blog
> -    include_once( PLOG_CLASS_PATH."blog.php" );
> +    include( PLOG_CLASS_PATH."blog.php" );

include_once() would work here fine, but it isn't needed.


Or in places like this:

> Modified: plog/branches/lifetype-1.2/class/config/configfilestorage.class.php
> -        	   include( $this->_configFile );
> -        	   $this->_props = new Properties( $config );
> -        	   $result = true;
> +                    // Note: It is correct to not use lt_include() here
> +                include( $this->_configFile );
> +                $this->_props = new Properties( $config );
> +                $result = true;


> Modified: plog/branches/lifetype-1.2/class/controller/blogcontroller.class.php
>         function _loadActionMaps()
>         {
> +                // Note: this is an acceptable use of include()
> 			include( PLOG_CLASS_PATH."class/controller/controllermap.properties.php" );


There are a couple places like this where it would be interesting to see 
(from a performance standpoint) if this is being included lots of times, 
and if it is, there might be a better way of optimizing memory.

> Modified: plog/branches/lifetype-1.2/class/locale/locale.class.php
> +                    // TODO: this function is only called once, right?
>                 include( $fileName );


I didn't mean to check this in yet, but you can see my removal of 
include_once() which seems like it should be a better performance gain, 
and secondly, setting the global variable before including it - there are 
two circular references in our includes (Date.class.php and 
templatesets.class.php) that were causing our lt_include to be called 
twice, and the include_once was actually protecting the file from being 
included twice - that was tricky to track down.

> --- plog/branches/lifetype-1.2/class/object/loader.class.php	2007-04-26 21:19:34 UTC (rev 5347)
> 	function lt_include( $filename )
> 	{
> 		if(!isset($GLOBALS['included_files'][$filename] )) {
> -			include_once($filename);
> 			$GLOBALS['included_files'][$filename] = TRUE;
> +			include($filename);



More information about the pLog-svn mailing list