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.

Comments

juampynr’s picture

Status: Active » Needs review
StatusFileSize
new1 KB

Here is the patch.

merlinofchaos’s picture

Status: Needs review » Fixed

Validation is always a good idea, especially when not validating can result in whitescreens.

Committed and pushed! Thanks!

merlinofchaos’s picture

Status: Fixed » Needs work

This commit caused notice issues as noted in #1413192: Notice: Undefined index: path in ctools_get_plugins() (line 247 and had to be reverted.

juampynr’s picture

Status: Needs work » Needs review
StatusFileSize
new1.04 KB

Added an isset() condition to ensure that the array index exists before evaluating file existance.

merlinofchaos’s picture

Im 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?

juampynr’s picture

Sure, 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

wusel’s picture

May 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???

merlinofchaos’s picture

Maybe 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.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed.

prdctvtxt’s picture

Warning: file_exists() expects parameter 1 to be string, array given in ctools_get_plugins() (line 247 of ctools/includes/plugins.inc).
Patch attached.

ivan zugec’s picture

Status: Fixed » Needs review
tim.plunkett’s picture

Status: Needs review » Needs work
+++ b/includes/plugins.incundefined
@@ -244,7 +244,7 @@ function ctools_get_plugins($module, $type, $id = NULL) {
+      if (isset($cache->data['path']) && file_exists($cache->data['path']['file'])) {

Didn't confirm the fix, but from a code point of view, the isset should check $cache->data['path']['file'].

juampynr’s picture

They 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.

juampynr’s picture

Status: Needs work » Needs review

Changed status to needs review.

merlinofchaos’s picture

Status: Needs review » Fixed

am'd and pushed.

merlinofchaos’s picture

Status: Fixed » Active

Ok, 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.

juampynr’s picture

Status: Active » Needs review
StatusFileSize
new1.77 KB

This 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.

jaypark’s picture

Status: Needs review » Reviewed & tested by the community

juampy,

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:

 Chaos     Chaos tools (ctools)                  Module  Enabled                
 Core      Block (block)                         Module  Enabled        7.12    
 Core      Color (color)                         Module  Enabled        7.12    
 Core      Comment (comment)                     Module  Enabled        7.12    
 Core      Contact (contact)                     Module  Enabled        7.12    
 Core      Database logging (dblog)              Module  Enabled        7.12    
 Core      Field (field)                         Module  Enabled        7.12    
 Core      Field SQL storage                     Module  Enabled        7.12    
 Core      Field UI (field_ui)                   Module  Enabled        7.12    
 Core      File (file)                           Module  Enabled        7.12    
 Core      Filter (filter)                       Module  Enabled        7.12    
 Core      Help (help)                           Module  Enabled        7.12    
 Core      Image (image)                         Module  Enabled        7.12    
 Core      List (list)                           Module  Enabled        7.12    
 Core      Menu (menu)                           Module  Enabled        7.12    
 Core      Node (node)                           Module  Enabled        7.12    
 Core      Number (number)                       Module  Enabled        7.12    
 Core      Options (options)                     Module  Enabled        7.12    
 Core      Path (path)                           Module  Enabled        7.12    
 Core      PHP filter (php)                      Module  Enabled        7.12    
 Core      RDF (rdf)                             Module  Enabled        7.12    
 Core      Search (search)                       Module  Enabled        7.12    
 Core      Statistics (statistics)               Module  Enabled        7.12    
 Core      Syslog (syslog)                       Module  Enabled        7.12    
 Core      System (system)                       Module  Enabled        7.12    
 Core      Taxonomy (taxonomy)                   Module  Enabled        7.12    
 Core      Text (text)                           Module  Enabled        7.12    
 Core      Toolbar (toolbar)                     Module  Enabled        7.12    
 Core      Tracker (tracker)                     Module  Enabled        7.12    
 Core      Trigger (trigger)                     Module  Enabled        7.12    
 Core      Update manager (update)               Module  Enabled        7.12    
 Core      User (user)                           Module  Enabled        7.12    
 Data      Data (data)                           Module  Enabled        7.x-1.0 
 Data      Data Admin UI (data_ui)               Module  Enabled        7.x-1.0 
 Data      Data entity (data_entity)             Module  Enabled        7.x-1.0 
 Data      Data Node (data_node)                 Module  Enabled        7.x-1.0 
 Data      Data Search (data_search)             Module  Enabled        7.x-1.0 
 Data      Data Taxonomy (data_taxonomy)         Module  Enabled        7.x-1.0 
 Data      Data Visualization API                Module  Enabled        7.x-1.0 
 Database  Schema (schema)                       Module  Enabled        7.x-1.0 
 Date/Tim  Date (date)                           Module  Enabled                
 Date/Tim  Date All Day (date_all_day)           Module  Enabled                
 Date/Tim  Date API (date_api)                   Module  Enabled                
 Developm  Devel (devel)                         Module  Enabled        7.x-1.2 
 Developm  Devel node access                     Module  Enabled        7.x-1.2 
 Fields    Computed Field (computed_field)       Module  Enabled        7.x-1.0 
 Fields    Editable Fields (editablefields)      Module  Enabled        7.x-3.x 
 Fields    Entity Reference (entityreference)    Module  Enabled        7.x-1.0 
 Fields    Field extract (field_extract)         Module  Enabled                
 Fields    Node Reference (node_reference)       Module  Enabled                
 Fields    References (references)               Module  Enabled                
 Fields    User Reference (user_reference)       Module  Enabled                
 File      Filedepot (filedepot)                 Module  Enabled        7.x-1.0 
 Form      Hierarchical Select                   Module  Enabled        7.x-3.0 
 Homebox   Homebox (homebox)                     Module  Enabled        7.x-2.0 
 Javascri  Javascript timer api (jstimer)        Module  Enabled        7.x-1.3 
 Javascri  Widget: clock (jst_clock)             Module  Enabled        7.x-1.3 
 Javascri  Widget: timer (jst_timer)             Module  Enabled        7.x-1.3 
 Media     File entity (file_entity)             Module  Enabled        7.x-2.x 
 Media     IMCE (imce)                           Module  Enabled        7.x-1.5 
 Media     Media (media)                         Module  Enabled                
 Media     Media Browser Plus for Media 2.x      Module  Enabled                
 Media     Media Gallery (media_gallery)         Module  Enabled                
 Media     Media Internet Sources                Module  Enabled                
 Media     Media: Node (media_node)              Module  Enabled                
 Media     Plupload integration module           Module  Enabled                
 Organic   Organic groups (og)                   Module  Enabled                
 Organic   Organic groups context (og_context)   Module  Enabled                
 Organic   Organic groups migrate (og_migrate)   Module  Enabled                
 Organic   Organic groups UI (og_ui)             Module  Enabled        7.12    
 Other     Backup and Migrate (backup_migrate)   Module  Enabled        7.x-2.2 
 Other     Colorbox (colorbox)                   Module  Enabled                
 Other     Diff (diff)                           Module  Enabled        7.x-2.0 
 Other     Entity API (entity)                   Module  Enabled        7.x-1.0 
 Other     Entity tokens (entity_token)          Module  Enabled        7.x-1.0 
 Other     Format Number API (format_number)     Module  Enabled        7.x-1.x 
 Other     Libraries (libraries)                 Module  Enabled                
 Other     LoginToboggan (logintoboggan)         Module  Enabled        7.x-1.3 
 Other     Multiple forms (multiform)            Module  Enabled                
 Other     Pathauto (pathauto)                   Module  Enabled        7.x-1.0 
 Other     Remote stream wrapper                 Module  Enabled        7.x-1.0 
 Other     SSH public keys (sshkey)              Module  Enabled                
 Other     System stream wrapper                 Module  Enabled        7.x-1.0 
 Other     Term Reference Tree                   Module  Enabled        7.x-1.9 
 Other     Token (token)                         Module  Enabled        7.x-1.0 
 Other     Transliteration (transliteration)     Module  Enabled        7.x-3.0 
 Pathtrac  Pathtrack (pathtrack)                 Module  Enabled        7.x-0.1 
 Services  Services (services)                   Module  Enabled                
 Services  REST Server (rest_server)             Module  Enabled                
 Spaces    Spaces Taxonomy (spaces_taxonomy)     Module  Enabled        7.x-3.0 
 Spaces    Spaces UI (spaces_ui)                 Module  Enabled        7.x-3.0 
 Spaces    Spaces User (spaces_user)             Module  Enabled        7.x-3.0 
 Taxonomy  Taxonomy Menu (taxonomy_menu)         Module  Enabled        7.x-1.2 
 User      jQuery Update (jquery_update)         Module  Enabled        7.x-2.2 
 User      Wysiwyg (wysiwyg)                     Module  Enabled                
 UUID      Universally Unique ID (uuid)          Module  Enabled                
 Views     Views (views)                         Module  Enabled        7.x-3.3 
 Views     Views Bulk Operations                 Module  Enabled        7.x-3.0 
 Views     Views JSON (views_json)               Module  Enabled                
 Views     Views PHP (views_php)                 Module  Enabled        7.x-1.x 
 Views     Views RDF (views_rdf)                 Module  Enabled                
 Views     Views UI (views_ui)                   Module  Enabled        7.x-3.3 
 Views     Views XML (views_xml)                 Module  Enabled                
 Core      Seven (seven)                         Theme   Enabled        7.12    
 Other     AT Commerce (at_commerce)             Theme   Enabled        7.x-2.0 
 Other     AT Core (adaptivetheme)               Theme   Enabled        7.x-2.2 
 Other     AT Subtheme (adaptivetheme_subtheme)  Theme   Enabled        7.x-2.2 
 Other     Bluemarine (bluemarine)               Theme   Enabled        7.x-1.0 
 Other     Rubik (rubik)                         Theme   Enabled        7.x-4.0 
 Other     Tao (tao)                             Theme   Enabled        7.x-3.0 
juampynr’s picture

This 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.

juampynr’s picture

Any 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

jramby’s picture

hi,

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.

juampynr’s picture

jramby, have you tried to clear all the caches after that? I think that your issue with the menus belongs to a different bug.

jramby’s picture

StatusFileSize
new4.47 KB
new6.86 KB

After clearing all cache, the lost menus reappear like this :

normal menu after "drush cc all" command

And then just after, when i refresh the page the menu becom broken again!! like this :

Broken admin menu

Does anyone has this same behavior ?

jramby’s picture

Indeed, it was belonging to another bug http://drupal.org/node/442560 from admin_menu module.

So the patch on #17 worked for me!

thanks!

juampynr’s picture

Glad to hear that. I hope this patch gets applied soon.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed the revert. Thanks!

jlea9378’s picture

Status: Fixed » Needs review

I 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.

tim.plunkett’s picture

Status: Needs review » Fixed

The dev is too recent, this was the 18th commit, and yours only has up to the 17th. Try again tomorrow, it will be there.

juampynr’s picture

jlea9378: 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.

jlea9378’s picture

ok, I just downloaded the patch and applied it and it fixed it. Thx

maustyle’s picture

Hi, 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

juampynr’s picture

maustyle, apply the patch given at comment #17.

maustyle’s picture

Thanks juampy.

wxman’s picture

i 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.

ridgek’s picture

thanks for the patch, juampy!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.