I have a problem with my Drupal 7 site when my server reboot. The problem started when a module using SOAP (require_once('SOAP/Client.php');) was enabled.

When accessing my Drupal site after my server has rebooted, the site is not displayed and the following message is displayed in the browser:

--------------------------------------------------------------------------------

Fatal error: Cannot redeclare drupal_error_levels() in /usr/share/php/HTTP/Request.php on line 16 Call Stack: 0.0020 646768 1. {main}() /var/www/damco_berp/index.php:0 0.0108 1516288 2. drupal_bootstrap() /var/www/damco_berp/index.php:20 0.0840 9439400 3. _drupal_bootstrap_full() /var/www/damco_berp/includes/bootstrap.inc:2218 0.1281 16250152 4. module_load_all() /var/www/damco_berp/includes/common.inc:5114 0.4074 31574072 5. drupal_load() /var/www/damco_berp/includes/module.inc:24 0.4161 31724880 6. include_once('/var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/bsjasper.module') /var/www/damco_berp/includes/bootstrap.inc:1104 0.4197 31956544 7. require_once('/var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/includes/client.php') /var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/bsjasper.module:18 0.4227 32207672 8. require_once('/usr/share/php/SOAP/Client.php') /var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/includes/client.php:10 0.4525 34264480 9. require_once('/usr/share/php/SOAP/WSDL.php') /usr/share/php/SOAP/Client.php:29

--------------------------------------------------------------------------------

I tried to solve this problem, by adding the following lines to my settings.php (sites/default/settings.php):
error_reporting(E_ALL ^ E_DEPRECATED);
$conf['error_level'] = 2;
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

With this modification, after the server is rebooted, I still have the same behavior except for one thing. After the fatal error, if the browser page is refreshed (Ctrl+F5), my site is displayed correctly and everything work well until the next server reboot.

I have tried to modify some code to search for a solution:

In the file: includes/bootstrap.inc The function: _drupal_bootstrap_configuration()

I have temporary disabled the line: set_error_handler('_drupal_error_handler');

With this line commented out, every time the server reboot, my site is up and running ok, but I have warnings messages displayed at the top or bottom of the browser (deprecated function, strict warning, ....).

This site was running under Drupal 6 before and this problem was not present.

Any suggestions would be very appreciated!

Thanks in advance!

Regards,

N.B. The following text is the log file of my Server (Apache2 log) where we can see the PHP Fatal error:

--------------------------------------------------------------------------------

[Fri Sep 20 16:23:49 2013] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?) [Fri Sep 20 16:23:49 2013] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?) [Fri Sep 20 16:23:50 2013] [error] python_init: Python version mismatch, expected '2.6.5+', found '2.6.6'. [Fri Sep 20 16:23:50 2013] [error] python_init: Python executable found '/usr/bin/python'. [Fri Sep 20 16:23:50 2013] [error] python_init: Python path being used '/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'. [Fri Sep 20 16:23:50 2013] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads. [Fri Sep 20 16:23:50 2013] [notice] mod_python: using mutex_directory /tmp [Fri Sep 20 16:23:50 2013] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?) [Fri Sep 20 16:23:50 2013] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?) [Fri Sep 20 16:23:50 2013] [notice] Apache/2.2.16 (Debian) PHP/5.3.3-7+squeeze17 with Suhosin-Patch mod_python/3.3.1 Python/2.6.6 mod_ssl/2.2.16 OpenSSL/0.9.8o mod_perl/2.0.4 Perl/v5.10.1 configured -- resuming normal operations [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP Fatal error: Cannot redeclare drupal_error_levels() in /usr/share/php/HTTP/Request.php on line 16 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP Stack trace: [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 1. {main}() /var/www/damco_berp/index.php:0 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 2. drupal_bootstrap() /var/www/damco_berp/index.php:20 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 3. _drupal_bootstrap_full() /var/www/damco_berp/includes/bootstrap.inc:2218 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 4. module_load_all() /var/www/damco_berp/includes/common.inc:5114 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 5. drupal_load() /var/www/damco_berp/includes/module.inc:24 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 6. include_once() /var/www/damco_berp/includes/bootstrap.inc:1104 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 7. require_once() /var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/bsjasper.module:18 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 8. require_once() /var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/includes/client.php:10 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 9. require_once() /usr/share/php/SOAP/Client.php:29 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP Fatal error: Cannot redeclare class InsertQuery in /var/www/damco_berp/includes/database/query.inc on line 727 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP Stack trace: [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 1. {main}() /var/www/damco_berp/index.php:0 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 2. drupal_bootstrap() /var/www/damco_berp/index.php:20 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 3. _drupal_bootstrap_full() /var/www/damco_berp/includes/bootstrap.inc:2218 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 4. module_load_all() /var/www/damco_berp/includes/common.inc:5114 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 5. drupal_load() /var/www/damco_berp/includes/module.inc:24 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 6. include_once() /var/www/damco_berp/includes/bootstrap.inc:1104 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 7. require_once() /var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/bsjasper.module:18 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 8. require_once() /var/www/damco_berp/sites/all/modules/bnetsolution/modules/bsjasper/includes/client.php:10 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 9. require_once() /usr/share/php/SOAP/Client.php:29 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 10. _drupal_shutdown_function() /var/www/damco_berp/includes/bootstrap.inc:0 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 11. call_user_func_array() /var/www/damco_berp/includes/bootstrap.inc:3405 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 12. _drupal_session_write() /var/www/damco_berp/includes/session.inc:0 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 13. db_merge() /var/www/damco_berp/includes/session.inc:206 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 14. DatabaseConnection->merge() /var/www/damco_berp/includes/database/database.inc:2445 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 15. DatabaseConnection->getDriverClass() /var/www/damco_berp/includes/database/database.inc:841 [Fri Sep 20 16:24:02 2013] [error] [client 192.168.1.103] PHP 16. Database::loadDriverFile() /var/www/damco_berp/includes/database/database.inc:781

Comments

bnetsolutioninc’s picture

Finally after hard work, I have found a solution.

The problem was that one file in my module has the following line at the top:

require_once('SOAP/Client.php');

In the process of bootstrap, Drupal was including many times the file in question.

So, to prevent this unwanted situation, I have wrap the faulty line:

if (!function_exists('ws_checkUsername')) {
require_once('SOAP/Client.php');
}

With this fix, the SOAP/Client.php is only included once.

And everytime my server reboot, the site is up and running without the fatal error.

Today, I'm a happy programmer.....