+ $update_fields = DBStructure::getFieldsForTable('post-thread', $fields);
+ if (!empty($update_fields)) {
+ $affected_count = 0;
+ $posts = DBA::select('post-user-view', ['uri-id'], $thread_condition, ['group_by' => ['uri-id']]);
+ while ($rows = DBA::toArray($posts, false, 100)) {
+ $uriids = array_column($rows, 'uri-id');
+ if (!DBA::update('post-thread', $update_fields, ['uri-id' => $uriids])) {
+ DBA::rollback();
+ Logger::notice('Updating post-thread failed', ['fields' => $update_fields, 'condition' => $condition]);
+ return false;
+ }
+ $affected_count += DBA::affectedRows();
+ }
+ DBA::close($posts);
+ $affected = max($affected, $affected_count);
+ }
+
+ $update_fields = DBStructure::getFieldsForTable('post-thread-user', $fields);
+ if (!empty($update_fields)) {
+ $affected_count = 0;
+ $posts = DBA::select('post-user-view', ['post-user-id'], $thread_condition);
+ while ($rows = DBA::toArray($posts, false, 100)) {
+ $thread_puids = array_column($rows, 'post-user-id');
+ if (!DBA::update('post-thread-user', $update_fields, ['post-user-id' => $thread_puids])) {
+ DBA::rollback();
+ Logger::notice('Updating post-thread-user failed', ['fields' => $update_fields, 'condition' => $condition]);
+ return false;
+ }
+ $affected_count += DBA::affectedRows();
+ }
+ DBA::close($posts);
+ $affected = max($affected, $affected_count);
+ }
+
+ DBA::commit();
+
+ Logger::info('Updated posts', ['rows' => $affected]);
+ return $affected;
+ }
+
+ /**
+ * Delete a row from the post table
+ *
+ * @param array $conditions Field condition(s)
+ * @param array $options
+ * - cascade: If true we delete records in other tables that depend on the one we're deleting through
+ * relations (default: true)
+ *
+ * @return boolean was the delete successful?
+ * @throws \Exception
+ */
+ public static function delete(array $conditions, array $options = [])
+ {
+ return DBA::delete('post', $conditions, $options);