I just upgraded my server to PHP 5.5 and Apache 2.4 as the PPA I was using pushed out the upgrades.
(https://launchpad.net/~ondrej/+archive/php5)
This causes any site with views installed to throw the following error:
"PHP Fatal error: Cannot redeclare class view"
Sample error log line:
PHP Fatal error: Cannot redeclare class view in /unisonmirrored/aegir/platforms/drupal-7.22/sites/all/modules/views/includes/view.inc on line 19, referer: http://blog.timjacobs.net/event-results
PHP Fatal error: Cannot redeclare class view in /unisonmirrored/aegir/hostmaster-6.x-2.0-beta2/profiles/hostmaster/modules/views/includes/view.inc on line 18
I am using an aegir setup across two machines and the error is thrown by views on both Drupal 6 and Drupal 7 (as the hostmaster is Drupal 6 based, and my actual sites are all Drupal 7 based - using totally different directories/versions of views). The 7.x is running the latest views version available via drush.
Comment | File | Size | Author |
---|---|---|---|
#12 | Screenshot from 2014-03-11 00:44:20.png | 39.76 KB | stoickthevast |
Comments
Comment #1
geraldmelendez CreditAttribution: geraldmelendez commentedUPDATE: DON'T USE THE SOLUTION ABOVE, READ BELOW.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedThis has nothing to do with PHP 5.5. It's not valid to include a class twice in any version of PHP.
This has to do with somehow having two separate copies of Views being invoked in a way that shouldn't be possible. It's not really up to Views to defend against this stuff; it's a bug in whatever is including the second copy of Views.
Comment #3
geraldmelendez CreditAttribution: geraldmelendez commentedPLEASE DO NOT USE the solution in the initial post, you'll just be patching a symptom. As merlinofchaos stated, it is not Views' responsibility to make sure that a particular php file is included only once.
If you're getting this error make sure that you've resolved any error reported by watchdog first and then errors in your server's logs. I went through all my logs and config files and was able to figure out the problem. In my case Drupal was getting stuck trying to write a file to the /tmp directory and for some reason would include views.inc again.
Thanks Merlin!
-G
Comment #4
geraldmelendez CreditAttribution: geraldmelendez commentedAlso, check your APC or Xcache configs--start by disabling them to see if they are the culprits.
Comment #4.0
geraldmelendez CreditAttribution: geraldmelendez commentedAdded error log line for 7.x version
Comment #5
eyolf CreditAttribution: eyolf commentedI get the described behaviour on a fresh installation of drupal, with ctools and views installed and nothing else. So whatever is causing the error, it must be within the ctools/views sphere. I would therefore ask for the issue to be reopened.
For what it's worth, the error appears when I enable views-ui.
Configuration:
Apache: 2.4.6 (Ubuntu)
php: 5.5.3-1ubuntu2.1
drupal 7.25
views 7.x-3.7
Comment #6
danielbeeke CreditAttribution: danielbeeke commentedI have this same issue,
clean install and these versions:
http://pastebin.com/1MrKRiJh
Comment #7
danielbeeke CreditAttribution: danielbeeke commentedopcache.enable=0 in php.ini fixed this for me,
so it is a server configuration problem.
Comment #8
jlporter CreditAttribution: jlporter commentedSame as #7, never ever had a problem with xcache until I got bit by this. The built-in opcache included in php + xcache must be why there is a fatal can't redeclare(cached in both).
Comment #9
danielbeeke CreditAttribution: danielbeeke commentedI am using an opcache_blacklist now
[PATH TO YOUR SITE]/views/includes/view.inc
http://www.php.net/manual/en/opcache.configuration.php#ini.opcache.black...
Comment #10
arnaldoaa CreditAttribution: arnaldoaa commentedHi
i had this same problem,
i only disable php5-xcache and the site return to normal.
haa also stopped with error!
Comment #11
AlexisWilke CreditAttribution: AlexisWilke commentedI got the same problem and disabling xcache makes the site go back to normal.
Could it be a bug in the implementation of require_once() in X-Cache? Darn... sites are going to be slow without it...
Comment #12
stoickthevast CreditAttribution: stoickthevast commentedI got the same problem after installing php5-xcache.
PHP Fatal error: Cannot redeclare class view in ...
After digging for possible solution I found out that the problem is due to the value set in
xcache.mmap_path
. I changed it to/tmp/xcache
and it works as intended.Steps I did in my Ubuntu machine:
1. Increased the size of
xcache.size
to120M
in/etc/php5/mods-available/xcache.ini
.2. sudo service apache2 reload
See the attached screenshot.
My xcache.ini:
Not sure if this is the real cause of the problem.
UPDATE:
After several reload I'm again experiencing the WSOD. I manually clear the cache in Xcache admin and then reload the pages again and this time it is working fine.
Comment #13
ParisLiakos CreditAttribution: ParisLiakos commentedso whats the point of having both xcache and zend opcache enabled? disable one of them and error goes away.
zend opcache in in php core since 5.5 so i would disable xcache. here is a quick way to do this in .htaccess
Comment #14
ParisLiakos CreditAttribution: ParisLiakos commentedsorry didnt mean to change status. this is not a views problem
Comment #15
nonliquet CreditAttribution: nonliquet commentedSame as #7, thx, for the hint, Daniel!!
edit /etc/php5/apache2/php.ini
-> opcache.enable=0
Comment #16
acbramley CreditAttribution: acbramley commented#7 worked for us too, thanks
Comment #17
danielbeeke CreditAttribution: danielbeeke commented#7 is not a fix, it is a work arround.
Beter use #9
Still a work around but less cache destructive.
Comment #18
acbramley CreditAttribution: acbramley commented@danielbeeke actually it was a fix in our case as we accidentally had opcache AND xcache turned on, there for #7 was the right solution. Blacklisting a single class would've just made other classes throw the same errors.
Comment #19
paolomainardi CreditAttribution: paolomainardi commentedIn order to fix this issue with php 5.5 fpm you have to set this opcache variable:
opcache.dups_fix=1
See: http://php.net/manual/en/opcache.configuration.php#ini.opcache.dups-fix
Comment #20
erlingx CreditAttribution: erlingx commented#19 worked for me in .htaccess:
php_flag opcache.dups_fix TRUE
EDIT:
The error now comes 5 % of the time...
So used #13 instead. No problems.
Comment #21
mintonje CreditAttribution: mintonje commentedI was having this problem after moving from CentOS 5.11 (PHP 5.2.10, Zend v2.2.0) to Ubuntu 14.04.1 LTS (PHP 5.5.9, Zend v2.5.0).
Without doing my homework, I decided to install XCache also.
Since PHP 5.5 comes with Zend OPcache, I ended up with both enabled.
It looked like this:
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with XCache v3.1.0, Copyright (c) 2005-2013, by mOo
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with XCache Optimizer v3.1.0, Copyright (c) 2005-2013, by mOo
with XCache Cacher v3.1.0, Copyright (c) 2005-2013, by mOo
with XCache Coverager v3.1.0, Copyright (c) 2005-2013, by mOo
After some research, it seems that Zend OPcache provides the best performance between all of the PHP Cache options available, so I removed XCache and am using OPcache now and everything is working perfectly.
php -v now looks like this:
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
Here's a comparison of OPcache, XCache and No-Caching:
http://massivescale.blogspot.com/2013/06/php-55-zend-optimiser-opcache-v...
Comment #22
imkael CreditAttribution: imkael commentedafter half of my day digging between zend xcache apache2 and php config files i found this post and reply in #7 save my night thanks a lot
i try #13 and it works to
imkael
Comment #23
benelori CreditAttribution: benelori commented#13 worked for me as I didn't have any access to php.ini, so I had to modify the .htaccess.
Comment #24
hassebasse CreditAttribution: hassebasse commented# 13 saved my day, or should we say my Days. I have had terrible problems for a long period of time and as the problem has come and gone it has been a hassel to figure out what it was about. There have been no leads in the logs and today for the first time the error code put into index.php gave a clear answer and that took me to this discussion.
I use Xcache for Prestashop so I wanted to keep it so the solution in #13 is perfect for me, just to add it to .htaccess.
Many big thanks too all of you, but mostly to ParisLiakos !!!
Hans
Comment #25
DevElCuy CreditAttribution: DevElCuy commented#13 solves this issue!
Comment #26
DevElCuy CreditAttribution: DevElCuy at Dilygent commentedComment #27
DevElCuy CreditAttribution: DevElCuy at Dilygent commentedPlease see #13.
Comment #29
jentle07 CreditAttribution: jentle07 commentedI had the site problem white blank page regardless of any address or url, a long time ago when enabling "php5-xcache" for ubuntu server. The site used to work fine just before enabling the php5-xcache, so disabling the xcache just fixed the problem for good.
Today with a new server config I totally forgot about the xcache thing and installed fresh new drupal dev site for some testing, and facing this problem I found this forum, reminding me of the previous trouble I faced before.
Though the problem is less than before - at least apparently the site seems working except not updating and clearing caches and not doing cron jobs etc... So, If someone is on a ubuntu server with this same issue, if any better solution is not avail, just get rid of the xcache,
What I just did on the ubuntu server = In the terminal, just type and entered:
==> sudo apt-get --purge autoremove php5-xcache
After that I made apache server to restart (or not working or showing the result until the server restart)
==> service apache2 restart
You may have other better solutions not disabling this xcache, but I just wanted never have another same issue with drupal for good at least till the thing gets better working with drupal.
Comment #30
gmnowels CreditAttribution: gmnowels as a volunteer commentedHere is my php.ini info for blacklisting fix in #9 which is a workaround for now. Thxs, danielbeeke
and blacklist file is simply:
/var/www/drupal/sites/all/modules/contrib/views/includes/view.inc
I also changed a few other things from defaults including memory. Basically everything that is no longer commented out.
Comment #31
Vikas.Kumar CreditAttribution: Vikas.Kumar commentedSame as #7,
edit /etc/php5/apache2/php.ini
-> opcache.enable=0
Comment #32
opratr CreditAttribution: opratr as a volunteer commentedWe had this same issue after upgrading to PHP 5.6. The solution, which most have already discovered, was that we had two opcode caches running (Zend and XCache) by accident. Apparently an old xcache config sneaked back into our configuration during the upgrade (it had previously been disabled). Removing XCache solved the issue.
Comment #34
Vikram CreditAttribution: Vikram as a volunteer commented#13 is not help for me :( and #7 -> opcache.enable=0 is a very drastic solution I think, because if we have another webpages on the server it will be very slow, and as I heard, if we turn off opcache on the server for all webpages, the Drupal 8 will be not running. :(
So I think the best solution is to put: php_flag opcache.enable Off|| line in the .htaccess file only for the webpage which is not running with opcache. This is help for me!
Comment #35
pdxgimlet CreditAttribution: pdxgimlet commentedI was getting this error sporadically on various pages of my org's website. A few weeks ago, we switched from using Xcache to OPcache, so I had disabled Xcache for the VPS through the Dreamhost panel. However, looking at the phprc file saved on our VPS server (Dreamhost doesn't allow VPS users to manipulate the system php.ini file directly), this was at the bottom of the file twice:
Deleting those lines in the phprc file seem to have fixed the problem.
Comment #36
rajkumar7it74 CreditAttribution: rajkumar7it74 commentedopcache.enable=0 in php.ini fixed this for me,
Comment #37
rajkumar7it74 CreditAttribution: rajkumar7it74 commentedComment #38
oriol_e9gI have experienced the same problem and disable the opcache it's not a good solution because you are worsening the performance.
In my case this error is caused by a bad module upgrade process in the past. When we update a module normally simply drop the new files in the module folder, this is fine for new and updated files but if the new version have deleted an old file with this process removed files will remain, normally this unused files are hamless, just junk... but with opcache sometimes cause errors.
So, I have solved the problem simply with this steps:
Comment #39
zterry95 CreditAttribution: zterry95 commented#19 fixed my problem.
See php opcache official docs: http://php.net/manual/en/opcache.configuration.php#ini.opcache.dups-fix
Comment #40
darri CreditAttribution: darri commented#35 worked for me. Thanks pdxgimlet!
Comment #41
ownage CreditAttribution: ownage commented#35 also worked for me! (I'm also a Dreamhost user). Thanks pdxgimlet!