I enabled the module and immediately got this errror:

warning: Invalid argument supplied for foreach() in /opt/www/profiles/includes/common.inc on line 3185.
warning: Invalid argument supplied for foreach() in /opt/www/profiles/includes/common.inc on line 3106.
user warning: Table 'profiles.trustees_ip_authenticator' doesn't exist query: SELECT roles, id FROM trustees_ip_authenticator WHERE (ip1 = '2603567912') OR (ip2 <> 0 AND ip1 <= '2603567912' AND ip2 >= '2603567912') in /opt/www/profiles/sites/all/modules/ipAuthenticator/ipauth.module on line 126.

It's true, this table does not exist!

Comments

wdennen’s picture

Title: error » table does not exist error

(updating the issue title)

jonfrancisskydiver’s picture

wdennen,

Yes, the module does fail on installing. I have corrected the issue and committed a change to the development version. Drupal will repackage the update by tomorrow. In the mean time, if you just replace your ipauth.install file with the code below, you should be set to go once you make certain that the module is uninstalled. To make sure that a module is not installed, just make sure that the module isn't checked, and then goto the uninstall tab and follow the directions.

// $Id: ipauth.install,v 1.9 2008/10/28 15:03:48 jonfrancisskydiver Exp $
// Modified 2008/10/17 jonfrancisskydiver

/**
 * Implementation of hook_install().
 */
function ipauth_install() {

  if (!db_table_exists("ip_authenticator"))
    drupal_install_schema('ipauth');

  cache_clear_all();
  menu_rebuild();
}


/**
 * Implementation of hook_uninstall().
 */
function ipauth_uninstall() {
  if (db_table_exists("ip_authenticator")) {
    drupal_uninstall_schema('ipauth');
  }
  
  cache_clear_all('*', 'cache', TRUE);
  cache_clear_all('*', 'cache_filter', TRUE);
  cache_clear_all('*', 'cache_menu', TRUE);
  cache_clear_all('*', 'cache_page', TRUE);  
}


/**
 * Implementation of hook_schema().
 */
function ipauth_schema() {
  $schema['ip_authenticator'] = array(
    'description' => t('This table stores the single IP address and the IP ranges for specific user roles.'),
    'fields' => array(
      'id' => array(
        'description' => t('contains the unique ID for this IP authenticator'),
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'size' => 'normal'
      ),
      'ip1' => array(
        'description' => t('contains the first IP address'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'ip2' => array(
        'description' => t('contains the second IP address'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'roles' => array(
        'description' => t('Contains the role'),
        'type' => 'int',
        'size' => 'normal'
      ),
      'description' => array(
        'description' => t('contains the description of the ip authenticator'),
        'type' => 'varchar',
        'length' => '255',
        'not null' => FALSE,
        'default' => '',
      )
    ),
    'primary key' => array('id')
  );
  return $schema;
}

function ipauth_update_1() {
  
  $result = db_query("ALTER TABLE {ipAuthenticator} RENAME TO {ip_authenticator}", TRUE);
  
  $ret = array();
  $ret[] = array('success'=>$result!==FALSE, 'query'=>'Changed the name of ipAuthenticator table to ip_authenticator.');
}

/**
 * This update is writen to add the description field into the module's database table.
 */
function ipauth_update_2() {
  $ret = array();
  
  // Has the description field aready been added? if so, then don't run the sql statement and scare the user with a failed message.
  $result = db_query("SHOW COLUMNS FROM {ip_authenticator}");
  while($column = db_fetch_array($result)) {
    if ('description' == $column['Field']) {
      $ret[] = array('success' => TRUE, 'query' => t('The column, description, already exists in the database.  No update required.'));
      return $ret;
    }
  }
  
  // get the defined table structure.
  $schema = ipauth_schema();
  db_add_field($ret, 'ip_authenticator', 'description', $schema['ip_authenticator']['fields']['description']);

  // write the return array.
  drupal_set_message("IP authenticator update has ran and has completed its update on the database.");
  
  return $ret;
}
jonfrancisskydiver’s picture

Status: Active » Fixed
wdennen’s picture

thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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