You are here

function variablecheck_check_variables in Variable Check 7

Same name and namespace in other branches
  1. 6 variablecheck.module \variablecheck_check_variables()

Helper that returs a list of invalid variables and their values.

3 calls to variablecheck_check_variables()
variablecheck_check_variables_form in ./variablecheck.module
Helper that displays a form which allows users to delete variables that fail to unserialize, causing ugly Notices on production sites.
variablecheck_check_variables_form_validate in ./variablecheck.module
Ensure the form handler doesn't receive weird data that it shouldn't.
variablecheck_requirements in ./variablecheck.module
Implementation of hook_requirements()

File

./variablecheck.module, line 61

Code

function variablecheck_check_variables() {
  $rows = null;
  $select = db_select('variable', 'v')
    ->fields('v', array(
    'name',
    'value',
  ))
    ->orderBy('name', 'ASC')
    ->comment('Load all variables')
    ->execute();
  $entries = $select
    ->fetchAll();
  $rows = array();

  // Test each entry for validity.
  foreach ($entries as $entry) {

    // Suppress the notice.
    $value = @unserialize($entry->value);

    // If the unserialize call returned FALSE and the stored value is NOT a
    // boolean false, list it in the report.
    if ($value === FALSE && $entry->value != serialize(FALSE)) {
      $row = array(
        'name' => $entry->name,
        'value' => $entry->value,
      );
      $rows[$entry->name] = $row;
    }
  }
  return $rows;
}