aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-04-06 05:11:09 -0700
committerfriendica <info@friendica.com>2012-04-06 05:11:09 -0700
commit13dfb4012894c3bd724f12d75f4de7c1cce9529a (patch)
tree93023ac9c699863f4d9d2c9cbd122548346d1a15
parent0731c177eb4a58c6dd7bb50ee3915563c33531bc (diff)
downloadvolse-hubzilla-13dfb4012894c3bd724f12d75f4de7c1cce9529a.tar.gz
volse-hubzilla-13dfb4012894c3bd724f12d75f4de7c1cce9529a.tar.bz2
volse-hubzilla-13dfb4012894c3bd724f12d75f4de7c1cce9529a.zip
fix messed up config tables w/ duplicate entries
-rw-r--r--boot.php2
-rw-r--r--include/plugin.php2
-rw-r--r--update.php53
3 files changed, 51 insertions, 6 deletions
diff --git a/boot.php b/boot.php
index f4f44a644..1bc4c2a9a 100644
--- a/boot.php
+++ b/boot.php
@@ -11,7 +11,7 @@ require_once('include/cache.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '2.3.1303' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1136 );
+define ( 'DB_UPDATE_VERSION', 1137 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/include/plugin.php b/include/plugin.php
index e37ae8435..25fd32b4f 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -34,7 +34,7 @@ function install_plugin($plugin){
);
}
else {
- logger("Addons: FAILED installing " . $plugin);
+// logger("Addons: FAILED installing " . $plugin);
}
}}
diff --git a/update.php b/update.php
index 0c8486c31..1a36c754d 100644
--- a/update.php
+++ b/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1136 );
+define( 'UPDATE_VERSION' , 1137 );
/**
*
@@ -1152,12 +1152,57 @@ function update_1135() {
//so change charset to be smaller
q("ALTER TABLE `config` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL ,
CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL");
- //and add the index
- q("ALTER TABLE `config` ADD UNIQUE `access` ( `cat` , `k` ) ");
//same thing for pconfig
q("ALTER TABLE `pconfig` CHANGE `cat` `cat` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL ,
CHANGE `k` `k` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL");
-
+ // faulty update merged forward. Bad update in 1134 caused duplicate k,cat pairs
+ // these have to be cleared before the unique keys can be added.
+}
+
+function update_1136() {
+
+ $arr = array();
+
+ // order in reverse so that we save the newest entry
+
+ $r = q("select * from config where 1 order by id desc");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $found = false;
+ foreach($arr as $x) {
+ if($x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
+ $found = true;
+ q("delete from config where id = %d limit 1",
+ intval($rr['id'])
+ );
+ }
+ }
+ if(! $found) {
+ $arr[] = $rr;
+ }
+ }
+ }
+
+ $arr = array();
+ $r = q("select * from pconfig where 1 order by id desc");
+ if(count($r)) {
+ foreach($r as $rr) {
+ $found = false;
+ foreach($arr as $x) {
+ if($x['uid'] == $rr['uid'] && $x['cat'] == $rr['cat'] && $x['k'] == $rr['k']) {
+ $found = true;
+ q("delete from pconfig where id = %d limit 1",
+ intval($rr['id'])
+ );
+ }
+ }
+ if(! $found) {
+ $arr[] = $rr;
+ }
+ }
+ }
+ q("ALTER TABLE `config` ADD UNIQUE `access` ( `cat` , `k` ) ");
q("ALTER TABLE `pconfig` ADD UNIQUE `access` ( `uid` , `cat` , `k` )");
+
} \ No newline at end of file