PHP 4.3.0 required for News & other modules using templates?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
ChrisC

PHP 4.3.0 required for News & other modules using templates?

Post by ChrisC »

I just tracked down a problem where the News module would display its tabs, but none of the tabs contained any content.  Turns out this is an issue with the code to support the module_file_tpl resource type calling file_get_contents() which requires PHP >= 4.3.0 (according to  according to http://us3.php.net/file_get_contents ).  The site was running PHP Version 4.2.3.

If I'm understanding things correctly, I believe that either the system requirements should be changed from specifying PHP 4.1+ to calling for 4.3+ or this bit of code from module_file_template() in lib/content.functions.php  should be written differently:

$tpl_source = @file_get_contents(dirname(dirname(__FILE__)) . '/modules/' . $params[0] . '/templates/' . $params[1]);

The @ sign surpresses error reporting, which makes the behavior quite mysterious.

It looks like FCKEditorX and the Theme Manager module call file_get_contents as well.
Sam

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Sam »

I've been trying to get help on this problem for a while now and this is the most reliable answer yet. Makes perfect sense and hopefully, like you say, either the sys requirments or code can be changed as I know I'm not the only one with this problem.

Thanks.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Ted »

Ok, I found a decent workaround for systems that don't have this function.  I'm going to include it in the next release and hopefully 4.2 will be supported again (sorry!).

The code looks like:

Code: Select all

if(!function_exists("file_get_contents"))
{
   function file_get_contents($filename)
   {
       if(($contents = file($filename)))
       {
           $contents = implode('', $contents);
           return $contents;
       }
       else
           return false;
   }
}
and I just tossed it at the bottom of lib/misc.functions.php.  If anyone with a 4.2 system wants to test it, that would be great.  Thanks!
Sam

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Sam »

You beauty! Its working perfectly for me now (ver 4.2.2).

Was a little worried I'd have to move to another CMS due to time constraints, but you guys have been brilliantly helpful (as usual).

Thanks.
Alex_Leipzig

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Alex_Leipzig »

Thank you so much! It worked a charm!
Alex_Leipzig

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Alex_Leipzig »

Is that fix included in the 0.13 release? And do I really need MySQL 4 for it?
Last edited by Alex_Leipzig on Sun Jul 02, 2006 10:21 am, edited 1 time in total.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm
Location: Fairless Hills, Pa USA

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Ted »

Yes, that fix is in 0.13.

Do you mean that mysql 4 is required for 0.13?  I haven't tested it on mysql 3 in a long time....  so maybe.  :)  Keep in mind that the pretty url stuff requires php 4.3.3+ (it's in the README file now), so using 4.2.3 is going to be an issue with that.
Alex_Leipzig

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Alex_Leipzig »

Are pretty url's enabled by default?
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Elijah Lofgren »

alex wrote: Are pretty url's enabled by default?
In CMSMS 0.13 they are, in CMSMS 1.0-svn they have been turned off by default.

For how to turn them off see this: http://forum.cmsmadesimple.org/index.ph ... l#msg30261
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
Alex_Leipzig

Re: PHP 4.3.0 required for News & other modules using templates?

Post by Alex_Leipzig »

Thanks!
Locked

Return to “Modules/Add-Ons”