Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After the update at #715108: Make Merge queries more consistent and robust, I get a fatal error because the SPL autoloader includes the same database .inc file 2x for some reason. That makes it quite hard to recover.
For very little benefit, the autoloader uses require, unlike the rest of Drupal that uses require_once.
Example error:
Fatal error: Cannot redeclare class InsertQuery_mysql in ~/drupal-7/includes/database/mysql/query.inc on line
88 Call Stack: 0.0003 57396 1. {main}() ~/drupal-7/index.php:0 0.0111 505184 2. drupal_bootstrap()
Comment | File | Size | Author |
---|---|---|---|
#1 | 839006-SPL-require-once-1.patch | 767 bytes | pwolanin |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedComment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedouch. i think this patch is good regardless of #715108: Make Merge queries more consistent and robust, but i'd like to dig a bit into this. maybe its nothing, but worth a look. i don't think looking into this should stop this patch getting committed.
marking as RTBC, because its a trivial change.
Comment #3
Damien Tournoud CreditAttribution: Damien Tournoud commentedThe explanation is easy, we are trying to load MergeQuery_mysql:
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedI agree with that change. The require here is of very little benefit.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commented#3 oh, you mean MergeQuery_mysql. yes, that makes sense.
Comment #6
chx CreditAttribution: chx commentedhold! i want to discuss/understand.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commenteddiscussed this with chx in #drupal, i've created #839066: document that moving a class requires a registry rebuild in D7 so we document the new registry snafu's when a code update moves a class.
Comment #8
chx CreditAttribution: chx commentedOK then this is a go.
Comment #9
webchickLooks pretty straight-forward. Committed to HEAD. Thanks!
Comment #10
Berdir@3: I thought it is because we have multiple classes in that file and the file is loaded when one of these is used and when we are trying to load MergeQuery_mysql, the class is still not defined and the registry tries to load the file again. Your explanation sounds valid too ;)
Anyway, for the reference, performance shouldn't be a big problem anymore regarding require/require_once, see http://arin.me/blog/php-require-vs-include-vs-require_once-vs-include_on....