aboutsummaryrefslogtreecommitdiffstats
path: root/update.php
diff options
context:
space:
mode:
authorSimon L'nu <simon.lnu@gmail.com>2012-04-07 03:10:09 -0400
committerSimon L'nu <simon.lnu@gmail.com>2012-04-07 03:10:09 -0400
commitbc69a957dc875b699240827cb4af2691f8a8fcd6 (patch)
tree28442b76b1c8fec40235445d62b01c182f770b5f /update.php
parent43d5876e8b35d53a0bef5248c5d63e5bc209dbbf (diff)
parentecabe1d505464577fdc3d3ff0090371c8ca0cf1e (diff)
downloadvolse-hubzilla-bc69a957dc875b699240827cb4af2691f8a8fcd6.tar.gz
volse-hubzilla-bc69a957dc875b699240827cb4af2691f8a8fcd6.tar.bz2
volse-hubzilla-bc69a957dc875b699240827cb4af2691f8a8fcd6.zip
Merge branch 'master', remote-tracking branch 'remotes/upstream/master'
* remotes/upstream/master: ignore removed plugins fix messed up config tables w/ duplicate entries small fixes for the German strings fix bad sql update revert config changes, we're getting duplicate keys new-contacts-introductions in contacts-drop-down and new-messages in messages-drop-down get each an additional indicator... profile-picture is now scaled right in firefox... fixed broken css on introductions-page in firefox... * master:
Diffstat (limited to 'update.php')
-rw-r--r--update.php60
1 files changed, 55 insertions, 5 deletions
diff --git a/update.php b/update.php
index ae35d2d50..1a36c754d 100644
--- a/update.php
+++ b/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1135 );
+define( 'UPDATE_VERSION' , 1137 );
/**
*
@@ -1143,16 +1143,66 @@ q("ALTER TABLE `mail` ADD `unknown` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rep
}
function update_1134() {
+ // faulty update merged forward
+ // had a hardwired tablename of 'friendica' which isn't the right name on most systems
+}
+
+function update_1135() {
//there can't be indexes with more than 1000 bytes in mysql,
//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 `friendica`.`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");
-
- q("ALTER TABLE `friendica`.`pconfig` ADD UNIQUE `access` ( `uid` , `cat` , `k` )");
+ // 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