Forum: fix delete post

pull/4004/head
Angel Fernando Quiroz Campos 4 years ago
parent 9556f9d86f
commit 99703f6fc4
  1. 16
      public/main/forum/forumfunction.inc.php
  2. 2
      tests/behat/features/toolForum.feature

@ -897,16 +897,16 @@ function deletePost(CForumPost $post): void
*/ */
function getLastPostOfThread(int $threadId): array function getLastPostOfThread(int $threadId): array
{ {
$table_posts = Database::get_course_table(TABLE_FORUM_POST); $post = Container::getForumPostRepository()->findOneBy(['thread' => $threadId], ['postDate' => 'DESC']);
$sql = "SELECT iid, post_date FROM $table_posts
WHERE threadId = $threadId if (null === $post) {
ORDER BY post_date DESC LIMIT 1"; return [];
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
return Database::fetch_array($result);
} }
return []; return [
'iid' => $post->getIid(),
'post_date' => $post->getPostDate()->format('Y-m-d H:i:s'),
];
} }
/** /**

@ -53,7 +53,7 @@ Feature: Forum tool
Then I follow "Delete" Then I follow "Delete"
And I confirm the popup And I confirm the popup
And wait for the page to be loaded And wait for the page to be loaded
Then I should see "deleted" Then I should see "Thread deleted"
# This test is commented because to quote a message is necessary load HTML code inside of textarea. # This test is commented because to quote a message is necessary load HTML code inside of textarea.
# And this breaks the page for Behat # And this breaks the page for Behat

Loading…
Cancel
Save