Nov 21, 2008 | 08:22 PM  
Welcome

Don't have an account yet? You can create one, it is free, just click here

as a registered user you have some advantages like free downloads, comments and posting on our forums, depending upon this site's configuration and options.

 • •  Control Panel - Register - Login  • • 
Current Stable MDPro Lite 1.0821 Download
  Forum FAQForum FAQ   SearchSearch  UsergroupsUsergroups  PreferencesPreferences  Options forumOptions forum  Watched TopicsWatched Topics  Watched ForumsWatched Forums
Latest forum posts Latest forum posts  Log in to check your private messages Log in to check your private messages    Log inLog in 
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
MDMods.com
MD user level 5
MD user level 5


Joined: Jan 06, 2007
Posts: 55

Member
Post  Posted: Mar 11, 2007 - 03:30 AM Reply with quote Back to top
Post subject: Autorender problems

While working on a new module I found quite a major limitation of the system

I have a file to be placed in the MDPro root for displaying recent RSS posts. This calls to a template within a modue using atSmartyDisplay.

When this is attempted a error is received from Smarty saying it's unable to read the resource. After a bit of debugging this has been tracked down to the file_get_contents_from_smarty function in atAPI.php the problem is due to using $script_path=$GLOBALS['SCRIPT_FILENAME']; since my calling function isn't inside a module the $_smarty_compile_path used in the smarty fetch function is:

Code:
C:/xampp/xampp/htdocs/mdliterc2/test_rss.php/cache/_arcompile\%%1 E^1E1^1E125DFE%%user_rss.htm.php


Looks like Oleg noticed this problem as there are a few workarounds in place in atAPI.php for core MDPro files like:

Code:
$script_path=str_replace('/index.php','',$script_path);


I've modified this to check for any .php file that appears to be in the root, it all works fine for me, but Oleg will probably have to give it the once over

Remove from atAPI.php:

Code:
  $script_path=str_replace('/index.php','',$script_path);
  $script_path=str_replace('/modules.php','',$script_path);
  $script_path=str_replace('/admin.php','',$script_path);
  $script_path=str_replace('/user.php','',$script_path);


Replace with:

Code:
$script_path = preg_replace('/\/\\w+\.php/','',$script_path);


That way any .php file in the root will be stripped out of the $script_path statement before smarty tries to compile to an invalid directory

Also, I've found some problems with the usage of global $GLOBALS; which is used in atAPI.php. In certain installations I've found this seems to overwrite the $GLOBALS array with an empty array. There shouldn't be any need to declare $GLOBALS as a global as it's a superglobal that's accessible from anywhere. Just removing the global $GLOBALS; lines resolves the problem, but it will probably need testing on a few more systems

_________________
MDMods for all your MDLite module needs
View user's profile Visit poster's website
MDMods.com
MD user level 5
MD user level 5


Joined: Jan 06, 2007
Posts: 55

bannato
Post  Posted: Apr 29, 2007 - 12:44 AM Reply with quote Back to top

Took the time to benchmark these changes I'd recommended to file_get_contents_from_smarty.

I further optimized the preg_replace to match xxxx.php and \.. so no need for further str_replace's

Used ApacheBench on two test scripts, running 20,000 times on each:

My Version:
Time taken for tests: 47.640625 seconds

Existing MDPro Version:
Time taken for tests: 111.562500 seconds

The main reason for the slowdown is the explode statements. In the new version of atAPI, just use at_getScriptFileName instead. When I removed the explode statements the time for the MDPro version using str_replace took 71.95s to complete, so my version is 134% faster than the current version used in MDPro, and using one preg_replace is 51% faster than using multiple str_replaces

Both test cases and full results are attached, this version is now running at my site and I've not noticed any problems yet, so I've also attached the replacement version of atAPI.php but only the brave/experienced should give this a try as it simply hasn't been tested on enough systems to guarantee that it'll work in every configuration!

_________________
MDMods for all your MDLite module needs
View user's profile Visit poster's website
TiMax
Project Manager
Project Manager


Joined: July 31, 2003
Posts: 1560
Location: Quebec - Canada

Post  Posted: Apr 29, 2007 - 05:12 AM Reply with quote Back to top

Thanks for your contribution, I will test and check it asap

_________________
TiMaxMAX s.o.s.Fantasia e dinamicità Italiane, qualità e servizi Canadesi Web Services, hosting ed housing professionali
View user's profile Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:     
Jump to:  
All times are GMT + 13 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by MDForum 2.0.8© 2003-2007 MAXdev Team
Credits