* @link http://status.net/
*/
-if (!defined('STATUSNET')) {
- exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
class SchemaUpdater
{
*/
public function register($tableName, array $tableDef)
{
+ // Check if the table we're registering is related to a Managed_DataObject
+ if (is_a(ucfirst($tableName), 'Managed_DataObject', true)) {
+ call_user_func("{$tableName}::beforeSchemaUpdate");
+ }
+
$this->tables[$tableName] = $tableDef;
}
foreach ($this->tables as $table => $def) {
$checksum = $this->checksum($def);
if (empty($checksums[$table])) {
- common_log(LOG_DEBUG, "No previous schema_version for $table: updating to $checksum");
+ common_debug("No previous schema_version for $table: updating to $checksum");
} else if ($checksums[$table] == $checksum) {
- common_log(LOG_DEBUG, "Last schema_version for $table up to date: $checksum");
+ common_debug("Last schema_version for $table up to date: $checksum");
continue;
} else {
- common_log(LOG_DEBUG, "Last schema_version for $table is {$checksums[$table]}: updating to $checksum");
+ common_debug("Last schema_version for $table is {$checksums[$table]}: updating to $checksum");
}
//$this->conn->query('BEGIN');
$this->schema->ensureTable($table, $def);
{
$checksums = array();
- PEAR::pushErrorHandling(PEAR_ERROR_EXCEPTION);
try {
$sv = new Schema_version();
$sv->find();
return $checksums;
} catch (Exception $e) {
// no dice!
- common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet.");
+ common_debug("Possibly schema_version table doesn't exist yet.");
}
- PEAR::popErrorHandling();
return $checksums;
}
*/
protected function saveChecksum($table, $checksum)
{
- PEAR::pushErrorHandling(PEAR_ERROR_EXCEPTION);
try {
$sv = new Schema_version();
$sv->table_name = $table;
}
} catch (Exception $e) {
// no dice!
- common_log(LOG_DEBUG, "Possibly schema_version table doesn't exist yet.");
+ common_debug("Possibly schema_version table doesn't exist yet.");
}
- PEAR::popErrorHandling();
$this->checksums[$table] = $checksum;
}
}