From 150310ea3aa3c133a697c3ca924387d2ab0a9029 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 1 Sep 2014 23:41:21 +0200 Subject: [PATCH 1/4] dbstructure: Delete indexes before the database structure is changed --- include/dbstructure.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/dbstructure.php b/include/dbstructure.php index 45ba9b200d..c13d8fe5b6 100644 --- a/include/dbstructure.php +++ b/include/dbstructure.php @@ -117,6 +117,16 @@ function update_structure($verbose, $action) { if(false === $r) $errors .= t('Errors encountered creating database tables.').$name.EOL; } else { + // Drop the index if it isn't present in the definition + foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) + if (!isset($structure["indexes"][$indexname])) { + $sql2=db_drop_index($indexname); + if ($sql3 == "") + $sql3 = "ALTER TABLE `".$name."` ".$sql2; + else + $sql3 .= ", ".$sql2; + } + // Compare the field structure field by field foreach ($structure["fields"] AS $fieldname => $parameters) { if (!isset($database[$name]["fields"][$fieldname])) { @@ -140,16 +150,6 @@ function update_structure($verbose, $action) { } } } - // Drop the index if it isn't present in the definition - if (isset($database[$name])) - foreach ($database[$name]["indexes"] AS $indexname => $fieldnames) - if (!isset($structure["indexes"][$indexname])) { - $sql2=db_drop_index($indexname); - if ($sql3 == "") - $sql3 = "ALTER TABLE `".$name."` ".$sql2; - else - $sql3 .= ", ".$sql2; - } // Create the index foreach ($structure["indexes"] AS $indexname => $fieldnames) { @@ -354,7 +354,7 @@ function db_definition() { ), "indexes" => array( "PRIMARY" => array("id"), - "access" => array("cat(30)","k(30)"), + "cat_k" => array("cat(30)","k(30)"), ) ); $database["contact"] = array( @@ -890,7 +890,7 @@ function db_definition() { ), "indexes" => array( "PRIMARY" => array("id"), - "access" => array("uid","cat(30)","k(30)"), + "uid_cat_k" => array("uid","cat(30)","k(30)"), ) ); $database["photo"] = array( From b66a031b3487251c444598003d159f01e62d1c9d Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 2 Sep 2014 01:31:31 +0200 Subject: [PATCH 2/4] The plaintext conversion had issues with counting the text size of posts with german umlauts --- include/plaintext.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/plaintext.php b/include/plaintext.php index 56f0c7873d..cf0e209c06 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -172,10 +172,10 @@ function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2) { $msg = str_replace(" ", " ", $msg); // Twitter is using its own limiter, so we always assume that shortened links will have this length - if (strlen($link) > 0) + if (iconv_strlen($link, "UTF-8") > 0) $limit = $limit - 23; - if (strlen($msg) > $limit) { + if (iconv_strlen($msg, "UTF-8") > $limit) { if (!isset($post["url"])) { $limit = $limit - 23; From 961440e48fa5364ea049f418ec21cd295721925f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 2 Sep 2014 02:14:16 +0200 Subject: [PATCH 3/4] Cutting the text has to be made UTF-8 aware as well. --- include/plaintext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/plaintext.php b/include/plaintext.php index cf0e209c06..88febbfff8 100644 --- a/include/plaintext.php +++ b/include/plaintext.php @@ -116,7 +116,7 @@ function shortenmsg($msg, $limit, $twitter = false) { $msg = trim($msg."\n".$line); // Is the new message empty by now or is it a reshared message? elseif (($msg == "") OR (($row == 1) AND (substr($msg, 0, 4) == $recycle))) - $msg = substr(substr(trim($msg."\n".$line), 0, $limit), 0, -3)."..."; + $msg = iconv_substr(iconv_substr(trim($msg."\n".$line), 0, $limit, "UTF-8"), 0, -3, "UTF-8")."..."; else break; } From 7144d22cc1955ef78cb42c8c45eb3475f36c034e Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 2 Sep 2014 02:36:04 +0200 Subject: [PATCH 4/4] If a picture was too small it got cropped --- include/Photo.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/Photo.php b/include/Photo.php index fc2ce149c4..580fd25b6a 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -957,11 +957,16 @@ function store_photo($a, $uid, $imagedata = "", $url = "") { $image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt(); } - if (isset($image["thumb"])) - $image["preview"] = $image["thumb"]; + // Set the full image as preview image. This will be overwritten, if the picture is larger than 640. + $image["preview"] = $image["full"]; - if (isset($image["small"])) - $image["preview"] = $image["small"]; + // Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320 + //if (isset($image["thumb"])) + // $image["preview"] = $image["thumb"]; + + // Unsure, if this should be activated or deactivated + //if (isset($image["small"])) + // $image["preview"] = $image["small"]; if (isset($image["medium"])) $image["preview"] = $image["medium"];