After installing and enabling Schema on Drupal 7, I get an http 500 error when I choose the Admin configuration page or when I try to access the schema under structure. I have tried both the beta and devel build and get the same results. When I uninstall schema, everything works fine. There is nothing recorded in the error log regarding this event.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Status: Active » Postponed (maintainer needs more info)

Please test again with the latest 7.x-1.0-rc1 release. I'm unable to replicate this bug so far.

GuyPaddock’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Priority: Normal » Critical
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Verified.

After upgrading to MySQL 5.6 with PHP 5.3.3, I'm also seeing this behavior. I get the following error:
Fatal error: Call to a member function inspect() on a non-object in modules/contrib/schema/schema.module on line 396

Have tried to disable and uninstall Schema, then enable it again. Always the same behavior. When Schema is disabled, pages load fine. Even tried latest Dev.

GuyPaddock’s picture

Priority: Critical » Major
Issue tags: +autoslave, +replication, +schema

Okay, looks like schema_dbobject() is returning NULL. We're using autoslave with MASTER->SLAVE replication, so my guess is it isn't loading the right database class.

Here's our database config:

$databases['default']['default'] = array (
  'driver' => 'autoslave',
  'master' => array('master', 'autoslave'), // Fallback to slaves if master fails (read-only mode)
  'slave' => array('autoslave', 'master'), // Fallback to master if slaves fail
#  'invalidation path' => 'sites/default/files',
  'affected tables backend' => 'autoslave.affected_tables.memcache-db-accurate.inc',
  'watchdog on shutdown' => TRUE,
  'replication lag' => 2,
);

$databases['default']['master'] = array (
  'driver' => 'mysql',
  'database' => '***',
  'username' => '***',
  'password' => '***',
  'host' => '***',
);

$databases['default']['autoslave'] = array (
  'driver' => 'mysql',
  'database' => '***',
  'username' => '***',
  'password' => '***',
  'host' => '***',
  'readonly' => TRUE, // Required for system to enter "readonly" mode if master fails.
  'tables' => array('sessions', 'semaphore', 'watchdog', 'users', 'history'),
);

# Fix for drush
if (drupal_is_cli() || basename($_SERVER['PHP_SELF']) == 'update.php') {
  $databases['default']['default'] = $databases['default']['master'];
}

Setting down to "major" since this only affects Auto Slave users like ourselves.

GuyPaddock’s picture

Attached is a patch to make Schema able to work with Auto Slave.

GuyPaddock’s picture

Status: Active » Needs review

Setting to NR.

dobe’s picture

I am experiencing the same problem. The UI is not accessible. No errors. I do not have auto slave though either.

ybabel’s picture

worked for me

coreyp_1’s picture

Status: Needs review » Reviewed & tested by the community

This patch (#4) absolutely solves my problem on our production database. Thank you, GuyPaddock!!!

greggles’s picture

@dobe, @ybabel, @coreyp_1 - are you using a slave database at all? Can you post a redacted copy of your $databases array like GuyPaddock did? That would help to understand the bug and therefore understand if the fix is right.

dobe’s picture

I'm going to be honest. I don't remember this issue. Or the environment that it affected.

joachim’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -autoslave, -replication, -schema

Patch needs some clean-up work:

  1. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
      *
    

    Surplus blank line between @params.

  2. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    + *   The database target; defaults to 'default' when not using Auto Slave;
    

    What's Auto Slave (I googled and I found a band...?)

  3. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    +    if (empty($target)) {
    +      $target = 'default';
    

    Why not make 'default' the default for the parameter then, rather than NULL?

  4. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    +      // Special case for Auto Slave
    

    Missing full stop.

  5. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    +      }    ¶
    

    Whitespace.

  6. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    +    else {
    +      // Edge case; preferable to just getting a null-pointer "non object call"
    +      // error
    +      throw new RuntimeException('Database driver class not found: ' . $class_name);
    +    }
    

    This looks like an unrelated fix.

  7. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    + * <p>Determines the appropriate database "target" when the site is using
    + * MySQL master/slave replication with Auto Slave.</p>
    

    Lots of

    tags that shouldn't be here.

    Also, first paragraph of docblock should be a single line.

  8. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    +  if (!empty($info) && isset($info['default']) &&
    +      isset($info['default']['driver']) &&
    +      ($info['default']['driver'] == 'autoslave')) {
    +    if (!empty($info['default']['slave'])) {
    

    Please break this up into assignments to meaningful variables. I can't follow this at all.

  9. +++ b/schema.module	Fri Dec 06 16:27:42 2013 +0000
    @@ -127,22 +127,92 @@
    +      // Recommended name for slave from documentation
    

    More missing full stops.