HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Why is discussions sorting desc?

Hello

A fresh install of vanilla and it appears that the discussions list is sorted from oldest to newest. What might be wrong?

Tagged:
«1

Answers

  • KasparKaspar ✭✭
    edited April 6

    Could it be they are alphabetically sorted?

    If so check if it is set to "Flat" discussion type.

    https://success.vanillaforums.com/kb/articles/8-category-configuration-management


    Just to clear terms to avoid misunderstanding of what is referred:

    categories(list of other categories and/or discussion overview). With discussion display as set to "Discussions" it show latest first.


    Discussion view (listing comments in one discussion) show latest last.




    https://success.vanillaforums.com/kb/articles/293-basic-category-types


    I take "fresh install" as there have been no plugins added, so cause cannot be from that front.

  • Thanks a lot for your answer and your interest. I am aware of the terms, yes, no misunderstanding.

    There are some sample posts in my installation. The discussions view shows all of them in ascending time order.

    In the admin page, all are set to "discussion", the first option available there (not nested, not flat, not header).

    Also yes, in the admin panel I rearranged the categories using the mouse (drag and drop) expecting that this order applies in the categories view. Anyway, the sorting in the discussions view is not based on this alphabetical order of categories.

    If you want, you may check: http://www.osde.online/discussions, it is in Greek though.

    A detail I haven't mentioned; I installed 2021.003.RC2

  • KasparKaspar ✭✭

    I'll call an adult in VF.

    @R_J heeelp ;-)

  • R_JR_J Ex-Fanboy Munich Moderator

    Sorry, have been "out of order" the last few days. Who ever thinks mankind is the end and the top of the evolution still has its blind gut, I'd bet. Useless thing...

    There's an option for that. I need some more time to find how it spelled exactly, but I will look it up. Guess it is something with "sort" and/or "order" and you might already find it in config-defaults


    galanta
  • KasparKaspar ✭✭

    Uhuh oh. Did not even consider that.


    $Configuration['Garden']['Embed']['SortComments'] = 'desc';

    Is in defaults

    Put

    $Configuration['Garden']['Embed']['SortComments'] = 'asc';

    In

    conf/config.php

    galanta
  • KasparKaspar ✭✭

    I am not awake.

    That is for embed and comments.

    galanta
  • I had already found this option, it is mentioned somewhere in another post. But this option has to do with the sorting of comments inside a discussion.

    My problem is with the sorting of the discussion themselves in the discussion view. I would expect that the first one should be the one with the latest comment or, if no comment is there, with the latest submission of discussion.

    On the contrary, I see first what was posted first as a discussion and so on. If I post a new discussion now, it will go to the end of the list (not first) and posting a comment will not bring it first either.

  • R_JR_J Ex-Fanboy Munich Moderator

    Okay, I'd say adding this to the end of your conf/config.php should help

    $Configuration['Vanilla']['Discussions']['SortDirection'] = 'desc';


    galanta
  • Thank you for your interest.

    Though, I followed your advice and it didn't change behaviour.

    Any other things that I could check?

  • I think desc should be right. Asc is how it behaves now. I want the latest to be first. As it is here in openforums.

  • KasparKaspar ✭✭
    edited April 8
    $Configuration['Vanilla']['Discussions']['SortField'] ='d.DateLastComment';
    


    With R_J's line aswell


    Remember to clear cache



    Found in an old discussion

    https://open.vanillaforums.com/discussion/comment/180551/#Comment_180551

  • Well, I am afraid this doesn't work either.

    I followed the old post, although it refers to an older version of the forum. I also read other posts starting from there, but no actual luck.

    However, somebody proposed to go in debug mode and check the actual query string.

    How do I go to debug mode?

    The problem persists

  • KasparKaspar ✭✭

    You said, initially, it is a fresh install.

    Is it also a fresh db?


    Does it also happen if you make another fresh install? ( maybe something went haywire on the firdt install).

  • Well, I tried all recommendations, I ran the restructure and update tools, I also changed themes, switched to default one but nothing changhed.

    I disabled all active plugins and the same. All of them were activated by the admin area.

    It was a fresh install from scratch. Version 2021.003.RC2.

    This fresh install didn't work at the beginning and I had to follow advice found here, uploading the folder /addons/themes from the previous release, because it was not present at all. Then the forum worked.

    I am trying to avoid making a fresh install but I will probably do so to see what happens.

    Previously, I had installed verson 3 and it worked ok with the sorting stuff. Then I deleted everything (db included) and went on to 2021.003.RC2.

  • R_JR_J Ex-Fanboy Munich Moderator

    Give me a few minutes, I was just about to find out the exact SQLs you need to run on your database to get more information on the problem.


  • R_JR_J Ex-Fanboy Munich Moderator

    Please run the following SQLs:

    1. show create database TheNameOfYourVanillaDatabase;
    2. show create table GDN_Discussion;

    select d2.DiscussionID, d2.DateInserted, d2.DateLastComment
    from `GDN_Discussion` `d`
    join `GDN_Discussion` `d2` on d.DiscussionID = d2.DiscussionID
    left join `GDN_UserDiscussion` `w` on w.DiscussionID = d2.DiscussionID and w.UserID = 2
    order by `d`.`DateLastComment` desc;
    

    (took me a while to find out the last one)


    My assumption is, that the database collation or the date columns or "not ideal"


  • Ok, maybe... here are the results

    First one, result:

    CREATE DATABASE `xxxxx` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */

    Second:

    CREATE TABLE `GDN_Discussion` (
     `DiscussionID` int(11) NOT NULL AUTO_INCREMENT,
     `Type` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
     `ForeignID` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
     `CategoryID` int(11) NOT NULL,
     `InsertUserID` int(11) NOT NULL,
     `UpdateUserID` int(11) DEFAULT NULL,
     `FirstCommentID` int(11) DEFAULT NULL,
     `LastCommentID` int(11) DEFAULT NULL,
     `Name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
     `Body` text COLLATE utf8mb4_unicode_ci NOT NULL,
     `Format` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
     `Tags` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
     `CountComments` int(11) NOT NULL DEFAULT 0,
     `CountBookmarks` int(11) DEFAULT NULL,
     `CountViews` int(11) NOT NULL DEFAULT 1,
     `Closed` tinyint(4) NOT NULL DEFAULT 0,
     `Announce` tinyint(4) NOT NULL DEFAULT 0,
     `Sink` tinyint(4) NOT NULL DEFAULT 0,
     `DateInserted` datetime NOT NULL,
     `DateUpdated` datetime DEFAULT NULL,
     `InsertIPAddress` varbinary(16) DEFAULT NULL,
     `UpdateIPAddress` varbinary(16) DEFAULT NULL,
     `DateLastComment` datetime DEFAULT NULL,
     `LastCommentUserID` int(11) DEFAULT NULL,
     `Score` float DEFAULT NULL,
     `Attributes` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
     `RegardingID` int(11) DEFAULT NULL,
     PRIMARY KEY (`DiscussionID`),
     KEY `IX_Discussion_Type` (`Type`),
     KEY `IX_Discussion_ForeignID` (`ForeignID`),
     KEY `IX_Discussion_Announce` (`Announce`),
     KEY `IX_Discussion_DateInserted` (`DateInserted`),
     KEY `IX_Discussion_DateLastComment` (`DateLastComment`),
     KEY `IX_Discussion_RegardingID` (`RegardingID`),
     KEY `IX_Discussion_CategoryPages` (`CategoryID`,`DateLastComment`),
     KEY `IX_Discussion_CategoryInserted` (`CategoryID`,`DateInserted`),
     KEY `FK_Discussion_InsertUserID` (`InsertUserID`)
    ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
    

    Third one:

    8 2021-04-08 20:28:58 2021-04-08 20:28:58

    7 2021-04-05 20:47:48 2021-04-05 20:47:48

    6 2021-04-03 19:03:18 2021-04-03 19:03:18

    5 2021-03-15 09:44:24 2021-03-17 15:41:09

    2 2021-03-14 11:41:36 2021-03-14 11:41:36

  • R_JR_J Ex-Fanboy Munich Moderator

    No surprises here. The last SQL should be the one that is run against your database and it shows the expected order. Sorry, that was not what I expected. Can you send me the config.php and config-defaults.php via PM? I don't ask you to post them here in public because they contain sensitive data. You could post them here if you know what to remove, but you shouldn't risk to publish anything you wouldn't want to.


    The other approach would be to find out, which SQL is run against your database. That's possible, too, but somewhat more tedious. You would need to enable the general query log and find out where the log file is saved.

    "set global general_log = 1;" enables it, after that you should reload your forums front page

    "set global general_log = 0;"

    "show variables where Variable_name = 'general_log_file';"

    "show variables where Variable_name = 'datadir';"

    In the query log you would have to find the SQL that has built your Recent Discussions list. I assume it would be something with "d2" in it.


    Or we are able to make out what is happening by looking at your config files 😉


    Kaspar
Sign In or Register to comment.