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.
I have a little reset.php script (code shown below) in my Drupal root that I use to reset my HEAD testing installs. Up until recently, it's worked just fine. Now I've started getting the following error: "Fatal error: Call to undefined function db_and() in /home/davereid/Projects/drupal-head/includes/database/mysql/schema.inc on line 35"
reset.php:
// Show a confirm message before wiping everything out.
if (!isset($_GET['sure'])) {
echo '<a href="/reset.php?sure=yes">Are you sure?</a>';
exit();
}
// Bootstrap Drupal.
define('DRUPAL_ROOT', dirname(realpath(__FILE__)));
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// Get a listing of all modules and put the system module last.
$modules = drupal_system_listing('/\.module$/', 'modules', 'name', 0);
unset($modules['system']);
$modules = array_keys($modules);
$modules[] = 'system';
// Uninstall all module schemas.
foreach ($modules as $module) {
drupal_uninstall_schema($module);
}
// Redirect to the install page.
header('Location: install.php');
exit();
The only way I could fix this was by adding require_once DRUPAL_ROOT . '/includes/database/query.inc';
right after drupal_bootstrap()
. What is going on? Why isn't that file included?
Comment | File | Size | Author |
---|---|---|---|
#3 | 360113-dbtng-conditions-D7.patch | 2.46 KB | Dave Reid |
Comments
Comment #1
Crell CreditAttribution: Crell commentedquery.inc is lazy-loaded. Functions don't lazy load without help. The code in schema.inc is not helping it. That's why. :-)
Although I'd say the real problem is that we're using db_and() inside the schema object to begin with; the utility functions should never be used internally. I think that was probably part of #342503: Schema function findTables fails on postgres - wrong SQL, as that did a lot of mucking about inside the schema classes. Bad on me for not catching that. :-(
Since the conditional objects are not driver-overridable and I can't think of a reason they would be, we should probably just switch the db_and() calls to direct $and = new DatabaseCondition('and') calls.
Comment #2
Dave ReidOk here's a patch that removes any direct calls to db_and()/db_or() within /database/.* files.
Comment #3
Dave ReidThis time with the patch.
Comment #4
Crell CreditAttribution: Crell commentedPasses visual inspection and the bot likes it. (I do love being able to say that...)
Comment #5
webchickCommitted to HEAD. :)