You are here

function fb_devel_cron in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 fb_devel.module \fb_devel_cron()
  2. 7.3 fb_devel.module \fb_devel_cron()

Implementation of hook_cron().

Remove obsolete data from {users} table. Not a serious problem, just cruft in the database which should never have been saved. Clean it up.

File

./fb_devel.module, line 484
Makes development with Drupal for Facebook much easier. Keep this module enabled until you're confident your app works perfectly.

Code

function fb_devel_cron() {
  $limit = 10;
  $result = db_query('SELECT * FROM {users} WHERE data LIKE "%\\"app_specific\\"%" OR data LIKE "%\\"is_app_user\\"%" OR data LIKE "%\\"fbu\\"%" LIMIT %d', $limit);
  while ($account = db_fetch_object($result)) {
    $data = unserialize($account->data);

    // Clean out the bogus data.
    foreach (array(
      'app_specific',
      'username',
      'fbu',
      'info',
    ) as $key) {
      unset($data[$key]);
    }
    db_query("UPDATE {users} SET data='%s' WHERE uid=%d", serialize($data), $account->uid);
    if (fb_verbose()) {
      print t('Cleaned up data for user %name (%uid), it is now: !data', array(
        '%name' => $account->name,
        '%uid' => $account->uid,
        '!data' => '<pre>' . print_r($data, 1) . '</pre>',
      ));
    }
  }
}