/**
  * Returns a checksum that indicates whether the 'system' table was modified. It is not required to be 100%
  * accurate, its goal is to not return the whole 'system' table in the response if the content did not change.
  *
  * @return string|null 32-character checksum value or NULL if the checksum is not supported.
  */
 private function getExtensionChecksum()
 {
     // There are multiple ways to check when the 'system' table was updated.
     if (_cache_get_object('cache_bootstrap') instanceof DrupalDatabaseCache) {
         // Every time a "system" change is detected by Drupal, system_list_reset() gets called, which clears the
         // 'system_list' cache entry from the 'cache_bootstrap' cache bin. Right here we will check when the cache
         // entry was last recreated and use that as the checksum.
         $cacheRecreatedAt = $this->connection->query('SELECT created FROM {cache_bootstrap} WHERE cid = :cid', array(':cid' => 'system_list'))->fetchField();
         if (ctype_digit((string) $cacheRecreatedAt)) {
             // Only rely on this check if we actually get a valid numeric timestamp.
             return md5($cacheRecreatedAt);
         }
     }
     if ($this->connection->databaseType() === 'mysql') {
         // https://dev.mysql.com/doc/refman/5.0/en/checksum-table.html
         $checksum = $this->connection->query('CHECKSUM TABLE {system}')->fetchField(1);
         // The columns returned are 'Table' (eg. schema.system) and 'Checksum' (numeric value, eg. 290814144), so
         // fetch the second value.
         if (ctype_digit((string) $checksum)) {
             return md5($checksum);
         }
     }
     return null;
 }
Exemple #2
0
 public function databaseType()
 {
     return $this->connection->databaseType();
 }