Page 1 of 1

PHP 4.3.0 required for News & other modules using templates?

Posted: Thu Mar 09, 2006 4:05 am
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.

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

Posted: Wed Mar 15, 2006 4:19 pm
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.

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

Posted: Wed Mar 15, 2006 6:15 pm
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!

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

Posted: Mon Mar 20, 2006 9:50 am
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.

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

Posted: Tue Apr 04, 2006 2:59 pm
by Alex_Leipzig
Thank you so much! It worked a charm!

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

Posted: Sun Jul 02, 2006 10:14 am
by Alex_Leipzig
Is that fix included in the 0.13 release? And do I really need MySQL 4 for it?

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

Posted: Sun Jul 02, 2006 9:28 pm
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.

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

Posted: Mon Jul 03, 2006 4:12 pm
by Alex_Leipzig
Are pretty url's enabled by default?

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

Posted: Mon Jul 03, 2006 7:43 pm
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

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

Posted: Tue Jul 04, 2006 9:18 am
by Alex_Leipzig
Thanks!