I get this in the footer and I can't log in:

Fatal error: Cannot redeclare class InsertQuery_mysql in /Users/joachim/Sites/7-drupal/includes/database/mysql/query.inc on line 88

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Active » Postponed (maintainer needs more info)

Is this a fresh HEAD? What did you do to get that? etc

Damien Tournoud’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

We don't support HEAD to HEAD upgrades at this point. You will have to reinstall.

rogical’s picture

Version: 7.x-dev » 7.7
Status: Closed (won't fix) » Active

Fatal error: require_once(): Cannot redeclare class insertquery_mysql in /opt/difang/prod/qlkaixin/includes/database/database.inc on line 1717

caused by the following code:

$directory = 'public://qq_connect';
  $qq_connect_dir = file_prepare_directory(&$directory, $options = FILE_MODIFY_PERMISSIONS);
  if(!$qq_connect_dir) {
    $qq_connect_dir = drupal_mkdir('public://qq_connect', $mode = NULL, $recursive = FALSE, $context = NULL);
    if(!$qq_connect_dir) {
      drupal_set_message(t('Can not create qq_connect directory.'), $type = 'error', $repeat = TRUE);
      return false;
    }
  }
marcingy’s picture

Priority: Critical » Normal

This is not critical.

ScottyC’s picture

Priority: Normal » Critical

This error is critical for me, I can barely access anything. My site is down.

marcingy’s picture

Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

This is not a general problem therefore it is not critical. Please provide information about your install to help use trace the problem.

ScottyC’s picture

Hi marcingy,
This is more an apology and note for others. I wasn't aware that my rating of the issue would alter the rating for the issue in general. Sorry about that, I hope I haven't broken any group rules. I have had a quick look for some but to no avail. I am using Version 7.7 and had just installed the Collapse Text module and had rebooted my apache server. I was repeatedly getting this error and I could only occasionally access only the home page of my site before receiving the above error (hence my critical rating). In trying to provide you with some info from my error logs I rebooted the apache server again and low and behold, problem gone. Not sure why? I don't have the time to care about why either, just happy everything works again.
Thanks

Chi’s picture

Component: system.module » database system
Status: Postponed (maintainer needs more info) » Active

I got the same error after updating from 7.0 to 7.9.

Chi’s picture

Version: 7.7 » 7.9
Component: database system » system.module

The error goes away when I disabled APC extension in .htaccess.
php_flag apc.cache_by_default Off

Chi’s picture

Title: Cannot redeclare class InsertQuery_mysql » Opcode (APC) and drupal autoloader
chx’s picture

Status: Active » Closed (won't fix)

As pointed out in #10, not our problem. Try apc.include_once_override = 0

1kenthomas’s picture

See

http://stackoverflow.com/questions/4575341/php-with-apc-fatal-errors-can...

for more clarification on the nature of the issue. In particular, note that in addition to the apc.include_once_override = 0 solution, the underlying problem may be fixed in subsequent versions of APC.

phayes’s picture

Just to be clear, to fix this edit your php.ini file (or /etc/php/conf.d/apc.ini file) and add the following:

apc.include_once_override = 0

phayes’s picture

For those of you still running into this issue: We've found XCache to be a good alternative to APC

pamu777’s picture

apc.include_once_override = 0 does not help to me.
and I tried below, but still that does not help me. anyone know how to fix?
apc.include_once_override = 0
apc.canonicalize = 0
apc.stat = 0

dman’s picture

Thanks for this thread.
It gave me enough clues to confirm it seemed to be related to APC.
I'm running Acquia Dev Desktop (which has APC on by default) an on importing a new site, the site loaded once, then subsequent pages threw this error.

Restarting the Acquia stack made the problem go away.

damien_vancouver’s picture

I had this error on Debian Linux after restarting Apache using the "apache2ctl graceful" command.

The comment in #16 about restarting the whole dev stack gave me a hint. I used "/etc/init.d/apache2 restart" to restart the entire apache process, and the error went away!

omega8cc’s picture

No extra settings and no restarts will help. Upgrade your APC to 3.1.14 to avoid this known APC bug.

chilic’s picture

Status: Closed (won't fix) » Active

I using APC 3.1.9
Options on:
apc.include_once_override = 0
apc.canonicalize = 0
apc.stat = 0

get fatal error.

omega8cc’s picture

Status: Active » Closed (won't fix)

This is not a Drupal issue but APC bug. Please read #18

chilic’s picture

O! Thanks i see my mistake.

damien_vancouver’s picture

Getting this error consistently after a server upgrade now. The D7 site in question starts out fine after apache restart but soon WSOD's with our old friend:

[Tue Mar 05 12:27:47 2013] [error] [client ww.xx.yy.zz.] PHP Fatal error: Cannot redeclare class InsertQuery_mysql in /home/example/includes/database/mysql/query.inc on line 87

The APC version mentioned in #18, v3.1.14 with the memory fix ,has been pulled due to other problems in it. (See #1914294: APC 3.1.14 disappeared from PECL for more info about this).

So for now (March 2013) we are back to no working APC fix. I have found one workaround that always does the trick for me. Set your apc.shm_size=32M and no larger. 32M is the default size and for some reason the error is never triggered for me if I stick to that. My guess is that the default size does not cause the bug, which would maybe explain this problem being one that is hard to reproduce and fix.

Of course 90%+ of your PHP objects will probably be cache misses.. but that's a lot nicer than WSOD!

Here is my Debian /etc/php5/conf.d/apc.ini file that is working for me. It might work for you.

extension=apc.so
apc.enabled=1
apc.shm_size=32M
apc.max_file_size = 10M
apc.rfc1867 = 1

Please post here if you still get the errors after setting your config to use apc.shm_size=32M, and I will edit this post accordingly.

Now we wait for APC 3.1.15 to be released. Then maybe wait an extra week just to be sure ;)

willhise’s picture

Had the same issues. Tried all the solutions posted here. Dropping shm_size to 32M does work, but what's the point? APC is basically off at that point. I'm also not sure if this actually fixes the issue or just hides it since so little is actually in APC.

APC 3.1.14 has been pulled as stated above, so we're back to 3.1.13.

Here's what worked for us, based on the last comment on this post: http://help.getpantheon.com/pantheon/topics/fatal_error_require_once_can...

APC version 3.1.13
PHP 5.3
allow_call_time_pass_reference = on

We are tracking down all the places in the code that this happens and fixing them.

baisong’s picture

Here's a patch that prevents the redeclare error from happening.
Based off of the solution linked to in comment #23

We were running into the issue on OpenScholar with variable apc.include_once_override set to 0, APC version 3.1.3p1, in an Acquia environment that can't be upgraded.

omega8cc’s picture

BTW: since APC looks deprecated already, you should switch to Zend OPcache if you can:

https://twitter.com/omega8cc/status/348123637913624576
https://twitter.com/omega8cc/status/348121239342182400

It has an extra config options to prevent issue like this, and we have already switched to it in the BOA stack.

ianwesty’s picture

For anyone having the same issue with Acquia Dev Desktop Control Panel

Go to your php.ini in /Users/[username/Applications/acquia-drupal/php5_3/bin/
Search for apc.enabled=1
Change it to apc.enabled=0

Restart Acquia Dev Desktop and all should be fine.

ianwesty’s picture

For anyone having the same issue with Acquia Dev Desktop Control Panel

Go to your php.ini in /Users/[username]/Applications/acquia-drupal/php5_3/bin/
Search for apc.enabled=1
Change it to apc.enabled=0

Restart Acquia Dev Desktop and all should be fine.

ianwesty’s picture

For anyone having the same issue with Acquia Dev Desktop Control Panel

Go to your php.ini in /Users/[username]/Applications/acquia-drupal/php5_3/bin/
Search for apc.enabled=1
Change it to apc.enabled=0

Restart Acquia Dev Desktop and all should be fine.

edutrul’s picture

In my case, We didn't have apc enabled,

So What I did was the following:

in includes/database/mysql/query.inc

I added:

<?php
  if (!class_exists('InsertQuery_mysql')) {
    class InsertQuery_mysql extends InsertQuery {
    ........
    ........
    ...
  }///< At the bottom close the if conditinal with bracket
?>

Putting the above code resolved the bug for me.

But I think this requires further investigation in the core. Since require_once shouldn't call the same class twice?

Hope this helps somebody

best regards

qqboy’s picture

Issue summary: View changes

#9 chi helped me thanks

SproetS’s picture

Restarting Acquia DevDesktop (#16) helped me to be able to click trough the site again.
#26 (and #27 and #28) made the error go away (or hide?).

Thanks!