You are here

function oauthconnector_cron in OAuth Connector 7

Implements hook_cron().

File

./oauthconnector.module, line 388
OAuth Connector module

Code

function oauthconnector_cron() {

  // cleanout leftover connections
  // the token could have been removed by other cron runs.
  $query = db_select('oauthconnector_connections', 'c');
  $query
    ->leftJoin('oauth_common_token', 't', 't.tid=c.tid');
  $query
    ->fields('c')
    ->addField('t', 'tid', 'externetid');
  $results = $query
    ->isNULL('t.tid')
    ->execute();
  while ($result = $results
    ->fetch()) {
    db_delete('oauthconnector_connections')
      ->condition('tid', $result->tid)
      ->execute();
  }
}