define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5.1-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1203 );
+define ( 'DB_UPDATE_VERSION', 1210 );
/**
* @brief Constant with a HTML line break.
/**
* @brief Image storage quality.
- *
+ *
* Lower numbers save space at cost of image detail.
* For ease of upgrade, please do not change here. Change jpeg quality with
* $a->config['system']['jpeg_quality'] = n;
/**
* @name SSL Policy
- *
+ *
* SSL redirection policies
* @{
*/
/**
* @name Logger
- *
+ *
* log levels
* @{
*/
/**
* @name Cache
- *
+ *
* Cache levels
* @{
*/
/**
* @name Register
- *
+ *
* Registration policies
* @{
*/
/**
* @name Contact_is
- *
+ *
* Relationship types
* @{
*/
/**
* @name Update
- *
+ *
* DB update return values
* @{
*/
/**
* @name CP
- *
+ *
* Type of the community page
* @{
*/
/**
* @name Network
- *
+ *
* Network and protocol family types
* @{
*/
/**
* @name Notify
- *
+ *
* Email notification options
* @{
*/
/**
* @name Term
- *
+ *
* Tag/term types
* @{
*/
/**
* @name Namespaces
- *
+ *
* Various namespaces we may need to parse
* @{
*/
/**
* @name Activity
- *
+ *
* Activity stream defines
* @{
*/
/**
* @name Gravity
- *
+ *
* Item weight for query ordering
* @{
*/
/**
*
* class: App
- *
+ *
* @brief Our main application structure for the life of this page.
- *
+ *
* Primarily deals with the URL that got us here
* and tries to make some sense of it, and
* stores our page contents and config storage
/**
* @brief Register template engine class
- *
+ *
* If $name is "", is used class static property $class::$name
- *
+ *
* @param string $class
* @param string $name
*/
/**
* @brief Return template engine instance.
- *
+ *
* If $name is not defined, return engine defined by theme,
* or default
*
/**
* @brief Retrieve the App structure
- *
+ *
* Useful in functions which require it but don't get it passed to them
*/
function get_app() {
* and mark it uninstalled in the database (for now we'll remove it).
* Then go through the config list and if we have a plugin that isn't installed,
* call the install procedure and add it to the database.
- *
+ *
* @param App $a
*
*/
}
}
-/**
+/**
* @brief Wrapper for adding a login box.
- *
+ *
* @param bool $register
* If $register == true provide a registration link.
* This will most always depend on the value of $a->config['register_policy'].
* @param bool $hiddens
- *
+ *
* @return string
* Returns the complete html for inserting into the page
- *
+ *
* @hooks 'login_hook'
* string $o
*/
/**
* @brief Returns the user id of locally logged in user or false.
- *
+ *
* @return int|bool user id or false
*/
function local_user() {
/**
* @brief Returns contact id of authenticated site visitor or false
- *
+ *
* @return int|bool visitor_id or false
*/
function remote_user() {
* so plugins can take part in process :)
*
* @param (string|integer) $cmd program to run or priority
- *
+ *
* next args are passed as $cmd command line
* e.g.: proc_run("ls","-la","/tmp");
* or: proc_run(PRIORITY_HIGH, "include/notifier.php", "drop", $drop_id);
*
* @note $cmd and string args are surrounded with ""
- *
+ *
* @hooks 'proc_run'
* array $arr
*/
/**
* @brief Return full URL to theme which is currently in effect.
- *
+ *
* Provide a sane default if nothing is chosen or the specified theme does not exist.
- *
+ *
* @return string
*/
function current_theme_url() {
/**
* @brief get c-style args
- *
+ *
* @return int
*/
function argc() {
/**
* @brief Returns the value of a argv key
- *
+ *
* @param int $x argv key
* @return string Value of the argv key
*/
/**
* @brief Get the data which is needed for infinite scroll
- *
+ *
* For invinite scroll we need the page number of the actual page
* and the the URI where the content of the next page comes from.
* This data is needed for the js part in main.js.
* Note: infinite scroll does only work for the network page (module)
- *
+ *
* @param string $module The name of the module (e.g. "network")
* @return array Of infinite scroll data
* 'pageno' => $pageno The number of the actual page
if ($index["Index_type"] == "FULLTEXT")
continue;
+ if ($index['Key_name'] != 'PRIMARY' && $index['Non_unique'] == '0' && !isset($indexdata[$index["Key_name"]])) {
+ $indexdata[$index["Key_name"]] = array('UNIQUE');
+ }
+
$column = $index["Column_name"];
// On utf8mb4 a varchar index can only have a length of 191
// To avoid the need to add this to every index definition we just ignore it here.
if (is_null($definition))
$definition = db_definition($charset);
+ // Ensure index conversion to unique removes duplicates
+ $sql_config = "SET session old_alter_table=1;";
+ if ($verbose)
+ echo $sql_config."\n";
+ if ($action)
+ @$db->q($sql_config);
// Compare it
foreach ($definition AS $name => $structure) {
if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
$sql2=db_drop_index($indexname);
if ($sql3 == "")
- $sql3 = "ALTER TABLE `".$name."` ".$sql2;
+ $sql3 = "ALTER IGNORE TABLE `".$name."` ".$sql2;
else
$sql3 .= ", ".$sql2;
}
if (!isset($database[$name]["fields"][$fieldname])) {
$sql2=db_add_table_field($fieldname, $parameters);
if ($sql3 == "")
- $sql3 = "ALTER TABLE `".$name."` ".$sql2;
+ $sql3 = "ALTER IGNORE TABLE `".$name."` ".$sql2;
else
$sql3 .= ", ".$sql2;
} else {
if ($current_field_definition != $new_field_definition) {
$sql2=db_modify_table_field($fieldname, $parameters);
if ($sql3 == "")
- $sql3 = "ALTER TABLE `".$name."` ".$sql2;
+ $sql3 = "ALTER IGNORE TABLE `".$name."` ".$sql2;
else
$sql3 .= ", ".$sql2;
}
$sql2=db_create_index($indexname, $fieldnames);
if ($sql2 != "") {
if ($sql3 == "")
- $sql3 = "ALTER TABLE `".$name."` ".$sql2;
+ $sql3 = "ALTER IGNORE TABLE `".$name."` ".$sql2;
else
$sql3 .= ", ".$sql2;
}
killme();
}
+ if ($fieldnames[0] == "UNIQUE") {
+ array_shift($fieldnames);
+ $method .= ' UNIQUE';
+ }
+
$names = "";
foreach ($fieldnames AS $fieldname) {
if ($names != "")
),
"indexes" => array(
"PRIMARY" => array("id"),
- "cat_k" => array("cat(30)","k(30)"),
+ "cat_k" => array("UNIQUE", "cat(30)","k(30)"),
)
);
$database["contact"] = array(
),
"indexes" => array(
"PRIMARY" => array("id"),
- "uid_cat_k" => array("uid","cat(30)","k(30)"),
+ "uid_cat_k" => array("UNIQUE", "uid","cat(30)","k(30)"),
)
);
$database["photo"] = array(
if ($argc==2) {
switch ($argv[1]) {
+ case "dryrun":
+ update_structure(true, false);
+ return;
case "update":
update_structure(true, true);
set_config('system','build',DB_UPDATE_VERSION);
<?php
-define('UPDATE_VERSION' , 1203);
+define('UPDATE_VERSION' , 1210);
/**
*
function update_1202() {
$r = q("UPDATE `user` SET `account-type` = %d WHERE `page-flags` IN (%d, %d)",
dbesc(ACCOUNT_TYPE_COMMUNITY), dbesc(PAGE_COMMUNITY), dbesc(PAGE_PRVGROUP));
-}
-
-function update_1210() {
- // Convert config indexes to unique, old_alter_table=1 removes duplicates on ALTER IGNORE
- $r = q("SET session old_alter_table=1;");
- $r = q("ALTER TABLE config DROP INDEX cat_k");
- $r = q("ALTER IGNORE TABLE config ADD UNIQUE INDEX cat_k (cat, k)");
-
- $r = q("ALTER TABLE pconfig DROP INDEX uid_cat_k");
- $r = q("ALTER IGNORE TABLE pconfig ADD UNIQUE INDEX uid_cat_k (uid, cat, k)");
}
\ No newline at end of file