<?php
use Friendica\App;
+use Friendica\Core\System;
use Friendica\Core\Config;
require_once "boot.php";
$sql = sprintf("ALTER TABLE `%s` engine=InnoDB;", dbesc($table['TABLE_NAME']));
echo $sql."\n";
- $result = @$db->q($sql);
+ $result = dba::e($sql);
if (!dbm::is_result($result)) {
print_update_error($db, $sql);
}
// No valid result?
if (!dbm::is_result($adminlist)) {
- logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_WARNING);
+ logger(sprintf('Cannot notify administrators about update_id=%d, error_message=%s', $update_id, $error_message), LOGGER_NORMAL);
// Don't continue
return;
$body = sprintf($body, $error_message);
notification(array(
- 'type' => "SYSTEM_EMAIL",
+ 'type' => SYSTEM_EMAIL,
'to_email' => $admin['email'],
'preamble' => $preamble,
'body' => $body,
/*
+ @TODO deprecated code?
$email_tpl = get_intltext_template("update_fail_eml.tpl");
$email_msg = replace_macros($email_tpl, array(
'$sitename' => $a->config['sitename'],
- '$siteurl' => App::get_baseurl(),
+ '$siteurl' => System::baseUrl(),
'$update' => DB_UPDATE_VERSION,
'$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
));
- $subject=sprintf(t('Update Error at %s'), App::get_baseurl());
+ $subject=sprintf(t('Update Error at %s'), System::baseUrl());
require_once('include/email.php');
$subject = email_header_encode($subject,'UTF-8');
mail($a->config['admin_email'], $subject, $email_msg,
// Ensure index conversion to unique removes duplicates
if ($is_unique) {
if ($ignore != "") {
- $db->q("SET session old_alter_table=1;");
+ dba::e("SET session old_alter_table=1;");
} else {
- $r = $db->q("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
+ $r = dba::e("CREATE TABLE `".$temp_name."` LIKE `".$name."`;");
if (!dbm::is_result($r)) {
$errors .= print_update_error($db, $sql3);
return $errors;
}
}
- $r = @$db->q($sql3);
+ $r = @dba::e($sql3);
if (!dbm::is_result($r)) {
$errors .= print_update_error($db, $sql3);
}
if ($is_unique) {
if ($ignore != "") {
- $db->q("SET session old_alter_table=0;");
+ dba::e("SET session old_alter_table=0;");
} else {
- $r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
+ $r = dba::e("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
if (!dbm::is_result($r)) {
$errors .= print_update_error($db, $sql3);
return $errors;
}
- $r = $db->q("DROP TABLE `".$name."`;");
+ $r = dba::e("DROP TABLE `".$name."`;");
if (!dbm::is_result($r)) {
$errors .= print_update_error($db, $sql3);
return $errors;
}
- $r = $db->q("RENAME TABLE `".$temp_name."` TO `".$name."`;");
+ $r = dba::e("RENAME TABLE `".$temp_name."` TO `".$name."`;");
if (!dbm::is_result($r)) {
$errors .= print_update_error($db, $sql3);
return $errors;
$primary_keys = array();
foreach ($fields AS $fieldname => $field) {
$sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
- if (x($field,'primary') and $field['primary']!='') {
+ if (x($field,'primary') && $field['primary']!='') {
$primary_keys[] = $fieldname;
}
}
echo $sql.";\n";
if ($action)
- $r = @$db->q($sql);
+ $r = @dba::e($sql);
return $r;
}
),
"indexes" => array(
"PRIMARY" => array("id"),
- "iid" => array("iid"),
+ "iid" => array("UNIQUE", "iid"),
)
);
$database["spam"] = array(
"uid_created" => array("uid","created"),
"uid_commented" => array("uid","commented"),
"uid_wall_created" => array("uid","wall","created"),
+ "private_wall_received" => array("private","wall","received"),
)
);
$database["tokens"] = array(
"created" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"pid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"executed" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
+ "done" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
),
"indexes" => array(
"PRIMARY" => array("id"),
"pid" => array("pid"),
"parameter" => array("parameter(64)"),
"priority_created" => array("priority", "created"),
+ "executed" => array("executed"),
)
);
}
if (is_null($db)) {
- @include(".htconfig.php");
- require_once("include/dba.php");
+ @include ".htconfig.php";
+ require_once "include/dba.php";
$db = new dba($db_host, $db_user, $db_pass, $db_data);
- unset($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
}
if ($argc == 2) {