Steps to reproduce this error are detailed at http://drupal.org/node/1347894#comment-5366800
During registry rebuild process, Ctools is not checking that a cached plugin exists, which in multisite environments provokes that it adds duplicated plugins, which produces an integrity constraint error in the registry table. By verifying that a cached plugin's path actually exists we avoid this error.
There are a few related issues caused by this. I am certain about the ones related to Feeds module (referenced in the issue above) and I suspect that the following ones are produced for the same reason:
#1265564: PDOException due to class auto-loading registry when running a cache clear
#1224498: PDOException
#1283208: PDOException: SQLSTATE[23000]
I am attaching a patch that fixes this issue now.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | normal_admin_menu.png | 6.86 KB | jramby |
| #23 | broken_admin_menu.png | 4.47 KB | jramby |
| #17 | ctools-registry-rebuild-revert-changes-1371700-17.patch | 1.77 KB | juampynr |
| #13 | ctools-wrong-cached-files-added-to-registry-1371700-13.patch | 1.55 KB | juampynr |
| #10 | file_exists_expects_string_array_given-1371700.patch | 690 bytes | prdctvtxt |
Comments
Comment #1
juampynr commentedHere is the patch.
Comment #2
merlinofchaos commentedValidation is always a good idea, especially when not validating can result in whitescreens.
Committed and pushed! Thanks!
Comment #3
merlinofchaos commentedThis commit caused notice issues as noted in #1413192: Notice: Undefined index: path in ctools_get_plugins() (line 247 and had to be reverted.
Comment #4
juampynr commentedAdded an isset() condition to ensure that the array index exists before evaluating file existance.
Comment #5
merlinofchaos commentedIm a little worried about that causing us to not cache things we should. Can yo give explicit reproduction instructions for the issue this is resolving?
Comment #6
juampynr commentedSure, you can find them at http://drupal.org/node/1347894#comment-5366800
The error occurs because CTools adds cached plugins on hook_registry_files_alter() related to files that have changed its location (for example, because they were located at sites/drupal.localhost/modules/contrib/feeds and we copied the whole Drupal site to another directory with a different site name such as sites/drupalB.localhost).
Let me know if you need even more detailed instructions.
This is a common scenario when there is a Drupal site configured with a named site and some feeds created by Feeds module and you clone it to your local box and rename the named site to something such as site.localhost. I went down the line to Drupal core debugging this, but the fix in core is still under debate at #1372122: STOP the registry integrity constraint violation nightmare
Comment #7
wusel commentedMay be, I have (nearly) the same problem at http://drupal.org/node/1413192#comment-5501838
Please help my D7.10.
Thank you very much!
Or is this a problem of Feeds???
Comment #8
merlinofchaos commentedMaybe you posted this after I reverted the commit and before another -dev was rolled. -dev releases are not rolled as soon as commits are made, they happen only at midnight and noon GMT. So if you're posting within a few hours of a commit, you need to be patient and make sure you have a version of the code that contains the commit.
Comment #9
merlinofchaos commentedCommitted.
Comment #10
prdctvtxt commentedWarning: file_exists() expects parameter 1 to be string, array given in ctools_get_plugins() (line 247 of ctools/includes/plugins.inc).
Patch attached.
Comment #11
ivan zugec commentedComment #12
tim.plunkettDidn't confirm the fix, but from a code point of view, the isset should check
$cache->data['path']['file'].Comment #13
juampynr commentedThey are two different scenarios:
The file to add to the registry may be at $cache->data['path'] or at $cache->data['path']['file']. I did not know about the latter.
Here is a patch that considers both of them.
Comment #14
juampynr commentedChanged status to needs review.
Comment #15
merlinofchaos commentedam'd and pushed.
Comment #16
merlinofchaos commentedOk, this is actually causing another bug. #1508954: Line 253 - plugins.inc - Array to string conversion; parameter 1 to be string -- and that's because $cache->data['path'] doesn't actually exist. This whole piece of code is broken.
$cache can contain multiple plugins. And we can't afford to file_exists all of them; that completely defeats the purpose of caching. Which is leaving me to wonder ... when you move modules around in a file system, don't you need to cache clear anyway? the menu system is going to totally break too. This isn't just plugins, and I am struggling to see why we have performance degrading code in here to catch something that is very very rare and should be easily fixed with a drush cache clear anyway.
I believe this needs to be completely reverted and removed.
Comment #17
juampynr commentedThis is definitively a bug in core because cached entries are not deleted when the registry is being rebuilt. Checking for the existence of files is not the solution.
After reverting this logic to what it was when the issue was created and applying the patch I submitted at #1372122: STOP the registry integrity constraint violation nightmare (comment #14), both this issue and #1508954: Line 253 - plugins.inc - Array to string conversion; parameter 1 to be string get fixed.
Here is a patch to revert changes. Until the core patch gets committed we will have to tell people to apply it manually to avoid Registry Constraint Errors.
Comment #18
jaypark commentedjuampy,
what "core patch" are you referring to?
tested your patch (not on multisite) on local dev site (win7+xampp) with these modules on (list excludes custom packages, dependent on ctools) - remedies the issue afaik:
Comment #19
juampynr commentedThis one: http://drupal.org/node/1372122#comment-5854040
@jaypark: as your scenario does not use multi-site, it is indeed enough just to apply patch #17. However, people using the multi-site feature may need to apply the core patch if they find Integrity Constraint Errors when moving the database to a new site within sites directory.
Comment #20
juampynr commentedAny progress? Patch from comment #17 is waiting.
In the meantime, the related core fix has been committed at Drupal 8 and is close to get committed to Drupal 7. ref #1372122: STOP the registry integrity constraint violation nightmare
Comment #21
jramby commentedhi,
I had just updated my version from 7.10 to 7.12 and I got this bug http://drupal.org/node/1508954. Then I tryed to apply the patch #17 an it solved this current issue but It brakes the admin menu : Some menus has disappeared :(
Had I missed something?
thanks.
Comment #22
juampynr commentedjramby, have you tried to clear all the caches after that? I think that your issue with the menus belongs to a different bug.
Comment #23
jramby commentedAfter clearing all cache, the lost menus reappear like this :
And then just after, when i refresh the page the menu becom broken again!! like this :
Does anyone has this same behavior ?
Comment #24
jramby commentedIndeed, it was belonging to another bug http://drupal.org/node/442560 from admin_menu module.
So the patch on #17 worked for me!
thanks!
Comment #25
juampynr commentedGlad to hear that. I hope this patch gets applied soon.
Comment #26
merlinofchaos commentedCommitted and pushed the revert. Thanks!
Comment #27
jlea9378 commentedI just downloaded and installed the latest dev and am still getting the error:
Warning: file_exists() expects parameter 1 to be string, array given in ctools_get_plugins() (line 253 of /var/www/html/drupal_test/sites/all/modules/ctools/includes/plugins.inc).
Chaos tool suite (ctools) 7.x-1.0+17-dev (2012-Apr-26)
I opened plugins.inc and looked at it and it doesn't appear that the patch in #17 has been applied.
Comment #28
tim.plunkettThe dev is too recent, this was the 18th commit, and yours only has up to the 17th. Try again tomorrow, it will be there.
Comment #29
juampynr commentedjlea9378: if you want it today, you will have to clone the repository and checkout the dev branch.
See http://drupal.org/project/ctools/git-instructions.
Comment #30
jlea9378 commentedok, I just downloaded the patch and applied it and it fixed it. Thx
Comment #31
maustyle commentedHi, how can I get rid of this error on my website?
Warning: file_exists() expects parameter 1 to be string, array given in ctools_get_plugins() (line 253 of xxxxx/xxxxx/sites/all/modules/ctools/includes/plugins.inc).
Should I delete the ctools_object_cache data from the database?
Many thanks
Comment #32
juampynr commentedmaustyle, apply the patch given at comment #17.
Comment #33
maustyle commentedThanks juampy.
Comment #34
wxman commentedi don't know what I'm doing wrong but nothing is working for me. I manually applied the patch, tried to install purl, and the site crashes. I'm getting the same error too. I've even flushed all the caches just to be sure. It won't even let me run update.php.
Comment #35
ridgek commentedthanks for the patch, juampy!