merged from develop and increased DB-version

This commit is contained in:
Philipp Holzer 2018-07-04 23:44:11 +02:00
commit 19209f6826
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6
29 changed files with 3900 additions and 3515 deletions

View file

@ -1241,9 +1241,6 @@ class DBStructure
"ownerid" => ["owner-id"],
"uid_uri" => ["uid", "uri(190)"],
"resource-id" => ["resource-id"],
"contactid_allowcid_allowpid_denycid_denygid" => ["contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"], //
"uid_type_changed" => ["uid","type","changed"],
"contactid_verb" => ["contact-id","verb"],
"deleted_changed" => ["deleted","changed"],
"uid_wall_changed" => ["uid","wall","changed"],
"uid_eventid" => ["uid","event-id"],
@ -1261,6 +1258,7 @@ class DBStructure
"body" => ["type" => "mediumtext", "comment" => "item body content"],
"location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "text location where this item originated"],
"coord" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "longitude/latitude pair representing location where this item originated"],
"language" => ["type" => "text", "comment" => "Language information about this post"],
"app" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "application which generated this item"],
"rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
"rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
@ -1716,7 +1714,6 @@ class DBStructure
"created" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
"received" => ["type" => "datetime", "not null" => "1", "default" => NULL_DATE, "comment" => ""],
"global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"aid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""],
"uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"],
],
"indexes" => [

View file

@ -7,6 +7,7 @@ namespace Friendica\Database;
use Friendica\Core\Config;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use dba;
require_once 'include/dba.php';
@ -30,6 +31,9 @@ class PostUpdate
if (!self::update1206()) {
return;
}
if (!self::update1274()) {
return;
}
}
/**
@ -217,4 +221,58 @@ class PostUpdate
logger("Done", LOGGER_DEBUG);
return true;
}
/**
* @brief update the "item-content" table
*
* @return bool "true" when the job is done
*/
private static function update1274()
{
// Was the script completed?
if (Config::get("system", "post_update_version") >= 1274) {
return true;
}
logger("Start", LOGGER_DEBUG);
$fields = ['id', 'title', 'content-warning', 'body', 'location', 'tag', 'file',
'coord', 'app', 'rendered-hash', 'rendered-html', 'verb',
'object-type', 'object', 'target-type', 'target', 'plink',
'author-id', 'owner-id'];
$condition = ["`icid` IS NULL"];
$params = ['limit' => 10000];
$items = Item::select($fields, $condition, $params);
if (!DBM::is_result($items)) {
Config::set("system", "post_update_version", 1274);
logger("Done", LOGGER_DEBUG);
return true;
}
$rows = 0;
while ($item = Item::fetch($items)) {
// Clearing the author and owner data if there is an id.
if ($item['author-id'] > 0) {
$item['author-name'] = '';
$item['author-link'] = '';
$item['author-avatar'] = '';
}
if ($item['owner-id'] > 0) {
$item['owner-name'] = '';
$item['owner-link'] = '';
$item['owner-avatar'] = '';
}
Item::update($item, ['id' => $item['id']]);
++$rows;
}
dba::close($items);
logger("Processed rows: " . $rows, LOGGER_DEBUG);
return true;
}
}