Skip to content

Commit

Permalink
Merge pull request #2853 from annando/1610-bugfix-config
Browse files Browse the repository at this point in the history
The creation of unique keys failed for MariaDB
  • Loading branch information
tobiasd committed Oct 9, 2016
2 parents a1c6399 + 4322b56 commit a53d48f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion boot.php
Expand Up @@ -38,7 +38,7 @@
define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5.1-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1205 );
define ( 'DB_UPDATE_VERSION', 1206 );

/**
* @brief Constant with a HTML line break.
Expand Down
4 changes: 2 additions & 2 deletions include/Core/Config.php
Expand Up @@ -32,7 +32,7 @@ class Config {
public static function load($family) {
global $a;

$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s'", dbesc($family));
$r = q("SELECT `v`, `k` FROM `config` WHERE `cat` = '%s' ORDER BY `cat`, `k`, `id`", dbesc($family));
if(count($r)) {
foreach($r as $rr) {
$k = $rr['k'];
Expand Down Expand Up @@ -90,7 +90,7 @@ public static function get($family, $key, $default_value=null, $refresh = false)
}
}

$ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' LIMIT 1",
$ret = q("SELECT `v` FROM `config` WHERE `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1",
dbesc($family),
dbesc($key)
);
Expand Down
4 changes: 2 additions & 2 deletions include/Core/PConfig.php
Expand Up @@ -29,7 +29,7 @@ class PConfig {
*/
public static function load($uid,$family) {
global $a;
$r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d",
$r = q("SELECT `v`,`k` FROM `pconfig` WHERE `cat` = '%s' AND `uid` = %d ORDER BY `cat`, `k`, `id`",
dbesc($family),
intval($uid)
);
Expand Down Expand Up @@ -83,7 +83,7 @@ public static function get($uid, $family, $key, $default_value = null, $refresh
}
}

$ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' LIMIT 1",
$ret = q("SELECT `v` FROM `pconfig` WHERE `uid` = %d AND `cat` = '%s' AND `k` = '%s' ORDER BY `id` DESC LIMIT 1",
intval($uid),
dbesc($family),
dbesc($key)
Expand Down
5 changes: 3 additions & 2 deletions include/dbstructure.php
Expand Up @@ -166,7 +166,8 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
@$db->q($sql_config);

// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
if (version_compare($db->server_info(), '5.7.4') >= 0) {
if ((version_compare($db->server_info(), '5.7.4') >= 0) AND
!(strpos($db->server_info(), 'MariaDB') !== false)) {
$ignore = '';
}else {
$ignore = ' IGNORE';
Expand Down Expand Up @@ -196,7 +197,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
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;
}
Expand Down
4 changes: 2 additions & 2 deletions update.php
@@ -1,6 +1,6 @@
<?php

define('UPDATE_VERSION' , 1205);
define('UPDATE_VERSION' , 1206);

/**
*
Expand Down Expand Up @@ -1727,4 +1727,4 @@ function update_1190() {
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));
}
}

0 comments on commit a53d48f

Please sign in to comment.