Merge pull request #1090 from annando/master

dbstructure: Delete indexes before the database structure is changed
This commit is contained in:
fabrixxm 2014-09-02 08:28:15 +02:00
commit e21b653614
3 changed files with 24 additions and 19 deletions

View File

@ -957,11 +957,16 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
$image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt(); $image["thumb"] = $a->get_baseurl()."/photo/{$hash}-3.".$ph->getExt();
} }
if (isset($image["thumb"])) // Set the full image as preview image. This will be overwritten, if the picture is larger than 640.
$image["preview"] = $image["thumb"]; $image["preview"] = $image["full"];
if (isset($image["small"])) // Deactivated, since that would result in a cropped preview, if the picture wasn't larger than 320
$image["preview"] = $image["small"]; //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"])) if (isset($image["medium"]))
$image["preview"] = $image["medium"]; $image["preview"] = $image["medium"];

View File

@ -117,6 +117,16 @@ function update_structure($verbose, $action) {
if(false === $r) if(false === $r)
$errors .= t('Errors encountered creating database tables.').$name.EOL; $errors .= t('Errors encountered creating database tables.').$name.EOL;
} else { } 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 // Compare the field structure field by field
foreach ($structure["fields"] AS $fieldname => $parameters) { foreach ($structure["fields"] AS $fieldname => $parameters) {
if (!isset($database[$name]["fields"][$fieldname])) { 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 // Create the index
foreach ($structure["indexes"] AS $indexname => $fieldnames) { foreach ($structure["indexes"] AS $indexname => $fieldnames) {
@ -354,7 +354,7 @@ function db_definition() {
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"access" => array("cat(30)","k(30)"), "cat_k" => array("cat(30)","k(30)"),
) )
); );
$database["contact"] = array( $database["contact"] = array(
@ -890,7 +890,7 @@ function db_definition() {
), ),
"indexes" => array( "indexes" => array(
"PRIMARY" => array("id"), "PRIMARY" => array("id"),
"access" => array("uid","cat(30)","k(30)"), "uid_cat_k" => array("uid","cat(30)","k(30)"),
) )
); );
$database["photo"] = array( $database["photo"] = array(

View File

@ -116,7 +116,7 @@ function shortenmsg($msg, $limit, $twitter = false) {
$msg = trim($msg."\n".$line); $msg = trim($msg."\n".$line);
// Is the new message empty by now or is it a reshared message? // Is the new message empty by now or is it a reshared message?
elseif (($msg == "") OR (($row == 1) AND (substr($msg, 0, 4) == $recycle))) 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 else
break; break;
} }
@ -172,10 +172,10 @@ function plaintext($a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2) {
$msg = str_replace(" ", " ", $msg); $msg = str_replace(" ", " ", $msg);
// Twitter is using its own limiter, so we always assume that shortened links will have this length // 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; $limit = $limit - 23;
if (strlen($msg) > $limit) { if (iconv_strlen($msg, "UTF-8") > $limit) {
if (!isset($post["url"])) { if (!isset($post["url"])) {
$limit = $limit - 23; $limit = $limit - 23;