]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #1090 from annando/master
authorfabrixxm <fabrix.xm@gmail.com>
Tue, 2 Sep 2014 06:28:15 +0000 (08:28 +0200)
committerfabrixxm <fabrix.xm@gmail.com>
Tue, 2 Sep 2014 06:28:15 +0000 (08:28 +0200)
dbstructure: Delete indexes before the database structure is changed

include/Photo.php
include/dbstructure.php
include/plaintext.php

index fc2ce149c4b62fc6b4e6a065f3a41d15a5ae69b8..580fd25b6af8f4bcd4ce7ed241d40b6460bce666 100644 (file)
@@ -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"];
index 45ba9b200d651b8a9852d0630207555f45687815..c13d8fe5b6658d509f577461a6e8121bde3438ef 100644 (file)
@@ -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(
index 56f0c7873d9943299affb7039b3b3ed9ecb0755d..88febbfff858449fdec687cd35e6ac945e904eb0 100644 (file)
@@ -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;
        }
@@ -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;