include suggested changes

This commit is contained in:
Philipp 2022-07-13 00:23:12 +02:00
parent 6ef609f4fb
commit d74e57ef2c
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
18 changed files with 64 additions and 67 deletions

View File

@ -40,25 +40,19 @@ class DatabaseStructure extends \Asika\SimpleConsole\Console
{ {
protected $helpOptions = ['h', 'help', '?']; protected $helpOptions = ['h', 'help', '?'];
/** /** @var Database */
* @var Database
*/
private $dba; private $dba;
/**
* @var Cache /** @var Cache */
*/
private $configCache; private $configCache;
/**
* @var DbaDefinition /** @var DbaDefinition */
*/
private $dbaDefinition; private $dbaDefinition;
/**
* @var ViewDefinition /** @var ViewDefinition */
*/
private $viewDefinition; private $viewDefinition;
/**
* @var string /** @var string */
*/
private $basePath; private $basePath;
protected function getHelp() protected function getHelp()

View File

@ -192,7 +192,7 @@ class Installer
* @return bool true if the installation was successful, otherwise false * @return bool true if the installation was successful, otherwise false
* @throws Exception * @throws Exception
*/ */
public function installDatabase() public function installDatabase(): bool
{ {
$result = DBStructure::install(); $result = DBStructure::install();

View File

@ -142,6 +142,7 @@ class DBStructure
* Print out database error messages * Print out database error messages
* *
* @param string $message Message to be added to the error message * @param string $message Message to be added to the error message
*
* @return string Error message * @return string Error message
*/ */
private static function printUpdateError(string $message): string private static function printUpdateError(string $message): string
@ -155,6 +156,7 @@ class DBStructure
/** /**
* Perform a database structure dryrun (means: just simulating) * Perform a database structure dryrun (means: just simulating)
* *
* @return string Empty string if the update is successful, error messages otherwise
* @throws Exception * @throws Exception
*/ */
public static function dryRun(): string public static function dryRun(): string
@ -513,28 +515,28 @@ class DBStructure
$fields = DBA::selectToArray('INFORMATION_SCHEMA.COLUMNS', $fields = DBA::selectToArray('INFORMATION_SCHEMA.COLUMNS',
['COLUMN_NAME', 'COLUMN_TYPE', 'IS_NULLABLE', 'COLUMN_DEFAULT', 'EXTRA', ['COLUMN_NAME', 'COLUMN_TYPE', 'IS_NULLABLE', 'COLUMN_DEFAULT', 'EXTRA',
'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'], 'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?", ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
DBA::databaseName(), $table]); DBA::databaseName(), $table]);
$foreign_keys = DBA::selectToArray('INFORMATION_SCHEMA.KEY_COLUMN_USAGE', $foreign_keys = DBA::selectToArray('INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
['COLUMN_NAME', 'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'], ['COLUMN_NAME', 'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL", ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
DBA::databaseName(), $table]); DBA::databaseName(), $table]);
$table_status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES', $table_status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES',
['ENGINE', 'TABLE_COLLATION', 'TABLE_COMMENT'], ['ENGINE', 'TABLE_COLLATION', 'TABLE_COMMENT'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?", ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
DBA::databaseName(), $table]); DBA::databaseName(), $table]);
$fielddata = []; $fielddata = [];
$indexdata = []; $indexdata = [];
$foreigndata = []; $foreigndata = [];
if (DBA::isResult($foreign_keys)) { if (DBA::isResult($foreign_keys)) {
foreach ($foreign_keys as $foreign_key) { foreach ($foreign_keys as $foreign_key) {
$parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]]; $parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]];
$constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters); $constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters);
$foreigndata[$constraint] = $foreign_key; $foreigndata[$constraint] = $foreign_key;
} }
} }
@ -562,8 +564,8 @@ class DBStructure
$fielddata = []; $fielddata = [];
if (DBA::isResult($fields)) { if (DBA::isResult($fields)) {
foreach ($fields as $field) { foreach ($fields as $field) {
$search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)']; $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
$replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int']; $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
$field['COLUMN_TYPE'] = str_replace($search, $replace, $field['COLUMN_TYPE']); $field['COLUMN_TYPE'] = str_replace($search, $replace, $field['COLUMN_TYPE']);
$fielddata[$field['COLUMN_NAME']]['type'] = $field['COLUMN_TYPE']; $fielddata[$field['COLUMN_NAME']]['type'] = $field['COLUMN_TYPE'];
@ -585,13 +587,13 @@ class DBStructure
} }
$fielddata[$field['COLUMN_NAME']]['Collation'] = $field['COLLATION_NAME']; $fielddata[$field['COLUMN_NAME']]['Collation'] = $field['COLLATION_NAME'];
$fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT']; $fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT'];
} }
} }
return [ return [
'fields' => $fielddata, 'fields' => $fielddata,
'indexes' => $indexdata, 'indexes' => $indexdata,
'foreign_keys' => $foreigndata, 'foreign_keys' => $foreigndata,
'table_status' => $table_status 'table_status' => $table_status
]; ];
@ -722,7 +724,7 @@ class DBStructure
{ {
return DBA::exists('INFORMATION_SCHEMA.KEY_COLUMN_USAGE', return DBA::exists('INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL", ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
DBA::databaseName(), $table, $field]); DBA::databaseName(), $table, $field]);
} }
/** /**
@ -795,8 +797,8 @@ class DBStructure
if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) {
$user = [ $user = [
'verified' => true, 'verified' => true,
'page-flags' => User::PAGE_FLAGS_SOAPBOX, 'page-flags' => User::PAGE_FLAGS_SOAPBOX,
'account-type' => User::ACCOUNT_TYPE_RELAY, 'account-type' => User::ACCOUNT_TYPE_RELAY,
]; ];
DBA::insert('user', $user); DBA::insert('user', $user);
@ -872,7 +874,7 @@ class DBStructure
$permission = ''; $permission = '';
} }
$fields = ['id' => $set['psid'], 'uid' => $set['uid'], 'allow_cid' => $permission, $fields = ['id' => $set['psid'], 'uid' => $set['uid'], 'allow_cid' => $permission,
'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']; 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''];
DBA::insert('permissionset', $fields); DBA::insert('permissionset', $fields);
} }
DBA::close($sets); DBA::close($sets);
@ -902,7 +904,7 @@ class DBStructure
$isUpdate = false; $isUpdate = false;
$processes = DBA::select('information_schema.processlist', ['info'], [ $processes = DBA::select('information_schema.processlist', ['info'], [
'db' => DBA::databaseName(), 'db' => DBA::databaseName(),
'command' => ['Query', 'Execute'] 'command' => ['Query', 'Execute']
]); ]);

View File

@ -61,13 +61,14 @@ class DbaDefinition
} }
/** /**
* Get field data for the given table * Truncate field data for the given table
*
* @param string $table Name of the table to load field definitions for
* @param array $data data fields
* *
* @param string $table Tavle to load field definitions for
* @param array $data data fields
* @return array fields for the given * @return array fields for the given
*/ */
public function getFieldsForTable(string $table, array $data = []): array public function truncateFieldsForTable(string $table, array $data): array
{ {
$definition = $this->definition; $definition = $this->definition;
if (empty($definition[$table])) { if (empty($definition[$table])) {

View File

@ -466,7 +466,7 @@ class APContact
} }
// Limit the length on incoming fields // Limit the length on incoming fields
$apcontact = DI::dbaDefinition()->getFieldsForTable('apcontact', $apcontact); $apcontact = DI::dbaDefinition()->truncateFieldsForTable('apcontact', $apcontact);
if (DBA::exists('apcontact', ['url' => $apcontact['url']])) { if (DBA::exists('apcontact', ['url' => $apcontact['url']])) {
DBA::update('apcontact', $apcontact, ['url' => $apcontact['url']]); DBA::update('apcontact', $apcontact, ['url' => $apcontact['url']]);

View File

@ -130,7 +130,7 @@ class User
$fields['rel'] = Contact::SELF; $fields['rel'] = Contact::SELF;
} }
return DI::dbaDefinition()->getFieldsForTable('user-contact', $fields); return DI::dbaDefinition()->truncateFieldsForTable('user-contact', $fields);
} }
/** /**

View File

@ -2075,7 +2075,7 @@ class GServer
*/ */
public static function update(array $fields, array $condition): bool public static function update(array $fields, array $condition): bool
{ {
$fields = DI::dbaDefinition()->getFieldsForTable('gserver', $fields); $fields = DI::dbaDefinition()->truncateFieldsForTable('gserver', $fields);
return DBA::update('gserver', $fields, $condition); return DBA::update('gserver', $fields, $condition);
} }

View File

@ -46,7 +46,7 @@ class Post
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post', $data);
// Additionally assign the key fields // Additionally assign the key fields
$fields['uri-id'] = $uri_id; $fields['uri-id'] = $uri_id;
@ -525,7 +525,7 @@ class Post
// To ensure the data integrity we do it in an transaction // To ensure the data integrity we do it in an transaction
DBA::transaction(); DBA::transaction();
$update_fields = DI::dbaDefinition()->getFieldsForTable('post-user', $fields); $update_fields = DI::dbaDefinition()->truncateFieldsForTable('post-user', $fields);
if (!empty($update_fields)) { if (!empty($update_fields)) {
$affected_count = 0; $affected_count = 0;
$posts = DBA::select('post-user-view', ['post-user-id'], $condition); $posts = DBA::select('post-user-view', ['post-user-id'], $condition);
@ -542,7 +542,7 @@ class Post
$affected = $affected_count; $affected = $affected_count;
} }
$update_fields = DI::dbaDefinition()->getFieldsForTable('post-content', $fields); $update_fields = DI::dbaDefinition()->truncateFieldsForTable('post-content', $fields);
if (!empty($update_fields)) { if (!empty($update_fields)) {
$affected_count = 0; $affected_count = 0;
$posts = DBA::select('post-user-view', ['uri-id'], $condition, ['group_by' => ['uri-id']]); $posts = DBA::select('post-user-view', ['uri-id'], $condition, ['group_by' => ['uri-id']]);
@ -559,7 +559,7 @@ class Post
$affected = max($affected, $affected_count); $affected = max($affected, $affected_count);
} }
$update_fields = DI::dbaDefinition()->getFieldsForTable('post', $fields); $update_fields = DI::dbaDefinition()->truncateFieldsForTable('post', $fields);
if (!empty($update_fields)) { if (!empty($update_fields)) {
$affected_count = 0; $affected_count = 0;
$posts = DBA::select('post-user-view', ['uri-id'], $condition, ['group_by' => ['uri-id']]); $posts = DBA::select('post-user-view', ['uri-id'], $condition, ['group_by' => ['uri-id']]);
@ -593,7 +593,7 @@ class Post
$affected = max($affected, $affected_count); $affected = max($affected, $affected_count);
} }
$update_fields = DI::dbaDefinition()->getFieldsForTable('post-thread', $fields); $update_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread', $fields);
if (!empty($update_fields)) { if (!empty($update_fields)) {
$affected_count = 0; $affected_count = 0;
$posts = DBA::select('post-user-view', ['uri-id'], $thread_condition, ['group_by' => ['uri-id']]); $posts = DBA::select('post-user-view', ['uri-id'], $thread_condition, ['group_by' => ['uri-id']]);
@ -610,7 +610,7 @@ class Post
$affected = max($affected, $affected_count); $affected = max($affected, $affected_count);
} }
$update_fields = DI::dbaDefinition()->getFieldsForTable('post-thread-user', $fields); $update_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread-user', $fields);
if (!empty($update_fields)) { if (!empty($update_fields)) {
$affected_count = 0; $affected_count = 0;
$posts = DBA::select('post-user-view', ['post-user-id'], $thread_condition); $posts = DBA::select('post-user-view', ['post-user-id'], $thread_condition);

View File

@ -45,7 +45,7 @@ class Content
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-content', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-content', $data);
// Additionally assign the key fields // Additionally assign the key fields
$fields['uri-id'] = $uri_id; $fields['uri-id'] = $uri_id;
@ -68,7 +68,7 @@ class Content
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-content', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-content', $data);
// Remove the key fields // Remove the key fields
unset($fields['uri-id']); unset($fields['uri-id']);

View File

@ -52,7 +52,7 @@ class History
} }
$update = false; $update = false;
$changed = DI::dbaDefinition()->getFieldsForTable('post-history', $item); $changed = DI::dbaDefinition()->truncateFieldsForTable('post-history', $item);
unset($changed['uri-id']); unset($changed['uri-id']);
unset($changed['edited']); unset($changed['edited']);
foreach ($changed as $field => $content) { foreach ($changed as $field => $content) {

View File

@ -43,7 +43,7 @@ class Question
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-question', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-question', $data);
// Remove the key fields // Remove the key fields
unset($fields['uri-id']); unset($fields['uri-id']);

View File

@ -44,7 +44,7 @@ class QuestionOption
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-question-option', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-question-option', $data);
// Remove the key fields // Remove the key fields
unset($fields['uri-id']); unset($fields['uri-id']);

View File

@ -43,7 +43,7 @@ class Thread
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread', $data);
// Additionally assign the key fields // Additionally assign the key fields
$fields['uri-id'] = $uri_id; $fields['uri-id'] = $uri_id;
@ -66,7 +66,7 @@ class Thread
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread', $data);
// Remove the key fields // Remove the key fields
unset($fields['uri-id']); unset($fields['uri-id']);

View File

@ -44,7 +44,7 @@ class ThreadUser
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread-user', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread-user', $data);
// Additionally assign the key fields // Additionally assign the key fields
$fields['uri-id'] = $uri_id; $fields['uri-id'] = $uri_id;
@ -69,7 +69,7 @@ class ThreadUser
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-thread-user', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread-user', $data);
// Remove the key fields // Remove the key fields
unset($fields['uri-id']); unset($fields['uri-id']);

View File

@ -48,7 +48,7 @@ class User
return false; return false;
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-user', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-user', $data);
// Additionally assign the key fields // Additionally assign the key fields
$fields['uri-id'] = $uri_id; $fields['uri-id'] = $uri_id;
@ -82,7 +82,7 @@ class User
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-user', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-user', $data);
// Remove the key fields // Remove the key fields
unset($fields['uri-id']); unset($fields['uri-id']);

View File

@ -67,7 +67,7 @@ class UserNotification
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-user-notification', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-user-notification', $data);
$fields['uri-id'] = $uri_id; $fields['uri-id'] = $uri_id;
$fields['uid'] = $uid; $fields['uid'] = $uid;
@ -91,7 +91,7 @@ class UserNotification
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
} }
$fields = DI::dbaDefinition()->getFieldsForTable('post-user-notification', $data); $fields = DI::dbaDefinition()->truncateFieldsForTable('post-user-notification', $data);
// Remove the key fields // Remove the key fields
unset($fields['uri-id']); unset($fields['uri-id']);

View File

@ -74,7 +74,7 @@ class DbaDefinitionSqlWriter
$foreign_keys = []; $foreign_keys = [];
foreach ($tableStructure['fields'] as $fieldName => $field) { foreach ($tableStructure['fields'] as $fieldName => $field) {
$sql_rows[] = '`' . static::escape($fieldName) . '` ' . self::FieldCommand($field); $sql_rows[] = '`' . static::escape($fieldName) . '` ' . self::fieldCommand($field);
if (!empty($field['primary'])) { if (!empty($field['primary'])) {
$primary_keys[] = $fieldName; $primary_keys[] = $fieldName;
} }
@ -170,7 +170,7 @@ class DbaDefinitionSqlWriter
*/ */
public static function addTableField(string $fieldName, array $parameters): string public static function addTableField(string $fieldName, array $parameters): string
{ {
return sprintf("ADD `%s` %s", static::escape($fieldName), static::FieldCommand($parameters)); return sprintf("ADD `%s` %s", static::escape($fieldName), static::fieldCommand($parameters));
} }
/** /**
@ -183,7 +183,7 @@ class DbaDefinitionSqlWriter
*/ */
public static function modifyTableField(string $fieldName, array $parameters): string public static function modifyTableField(string $fieldName, array $parameters): string
{ {
return sprintf("MODIFY `%s` %s", static::escape($fieldName), self::FieldCommand($parameters, false)); return sprintf("MODIFY `%s` %s", static::escape($fieldName), self::fieldCommand($parameters, false));
} }
/** /**
@ -193,7 +193,7 @@ class DbaDefinitionSqlWriter
* @param boolean $create Whether to include PRIMARY KEY statement (unused) * @param boolean $create Whether to include PRIMARY KEY statement (unused)
* @return string SQL statement part * @return string SQL statement part
*/ */
public static function FieldCommand(array $parameters, bool $create = true): string public static function fieldCommand(array $parameters, bool $create = true): string
{ {
$fieldstruct = $parameters['type']; $fieldstruct = $parameters['type'];

View File

@ -122,7 +122,7 @@ class ExpirePosts
$rows = 0; $rows = 0;
$userposts = DBA::select('post-user', [], ["`uri-id` not in (select `uri-id` from `post`)"]); $userposts = DBA::select('post-user', [], ["`uri-id` not in (select `uri-id` from `post`)"]);
while ($fields = DBA::fetch($userposts)) { while ($fields = DBA::fetch($userposts)) {
$post_fields = DI::dbaDefinition()->getFieldsForTable('post', $fields); $post_fields = DI::dbaDefinition()->truncateFieldsForTable('post', $fields);
DBA::insert('post', $post_fields, Database::INSERT_IGNORE); DBA::insert('post', $post_fields, Database::INSERT_IGNORE);
$rows++; $rows++;
} }
@ -136,7 +136,7 @@ class ExpirePosts
$rows = 0; $rows = 0;
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", GRAVITY_PARENT]); $userposts = DBA::select('post-user', [], ["`gravity` = ? AND `uri-id` not in (select `uri-id` from `post-thread`)", GRAVITY_PARENT]);
while ($fields = DBA::fetch($userposts)) { while ($fields = DBA::fetch($userposts)) {
$post_fields = DI::dbaDefinition()->getFieldsForTable('post-thread', $fields); $post_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread', $fields);
$post_fields['commented'] = $post_fields['changed'] = $post_fields['created']; $post_fields['commented'] = $post_fields['changed'] = $post_fields['created'];
DBA::insert('post-thread', $post_fields, Database::INSERT_IGNORE); DBA::insert('post-thread', $post_fields, Database::INSERT_IGNORE);
$rows++; $rows++;
@ -151,7 +151,7 @@ class ExpirePosts
$rows = 0; $rows = 0;
$userposts = DBA::select('post-user', [], ["`gravity` = ? AND `id` not in (select `post-user-id` from `post-thread-user`)", GRAVITY_PARENT]); $userposts = DBA::select('post-user', [], ["`gravity` = ? AND `id` not in (select `post-user-id` from `post-thread-user`)", GRAVITY_PARENT]);
while ($fields = DBA::fetch($userposts)) { while ($fields = DBA::fetch($userposts)) {
$post_fields = DI::dbaDefinition()->getFieldsForTable('post-thread-user', $fields); $post_fields = DI::dbaDefinition()->truncateFieldsForTable('post-thread-user', $fields);
$post_fields['commented'] = $post_fields['changed'] = $post_fields['created']; $post_fields['commented'] = $post_fields['changed'] = $post_fields['created'];
DBA::insert('post-thread-user', $post_fields, Database::INSERT_IGNORE); DBA::insert('post-thread-user', $post_fields, Database::INSERT_IGNORE);
$rows++; $rows++;