Saturday, June 11, 2011

Solved: Maximum execution time exceeded file.inc on line 934

Some people at Harvard University have greeted a template extension on the basic Drupal installation named OpenScholar. OpenScholar is intended to provide people with a Drupal installation which can be used to host a website for professors and research groups primarily. Looking at the templates they have build I wanted to give it a go. The installation is basically the same as that of standard Drupal. During installation of OpenScholar I encountered a issue which is also in some cases seen when you install Drupal itself. After the first installation page your webserver comes back with a empty page, looking at the HTML source code of the "empty" page it turns out the following error message is thrown:

Fatal error: Maximum execution time of 65 seconds exceeded in /public_html/includes/file.inc on line 934

The maximum exception time is set in your PHP configuration, this indicates the amount of seconds that a script can take to complete its task. You can resolve this by simply changing the value to something higher. Issue with this is that if you are on a hosted environment, like at a hosting provider, you will not have the option to change this value as it is set for all users on that webserver. Some options are available to you however. First is, you can add a setting to your local .htaccess file where you can change it for that specific directory. You have to add a php_value max_execution_time to this file. Secondly you can initiate a override in your PHP code itself. 

However, most hosting providers will have set a setting preventing such overrides in their main PHP configuration. This is a simple and good approach from a hosting provider point of view. This is preventing certain user to consume all CPU power with bad code. For most users those options will not be valid as was in my case as I installed it not on my own server and was trying to install it on a server at a hosting provider.

Meaning we have to look into other options to resolve this issue. Looking at the code we found that the issue is coming from a part of the code that is checking the files on the file system to verify that all files needed for the installation are present. This scanning of the filesystem in some cases take more time than the time set for the max execution time. With some help from Sam Adams and his postings on acquia.com forums I found that you can prevent this scan from happening by hacking the install.inc file. What you have to do is open the file in VI and change the following line:

$installs = drupal_get_install_files($module_list);

into this:

$installs = array();

This will populate the variable $installs with a empty array and it will not call drupal_get_install_files with a list of modules to be checked. After making this change the installation go's without any issue. 

Posted via Johan Louwers his Posterous page to his blogger page.

Post a Comment