Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Need to sort discussions by Date Created, not Most Recent Comment

2

Comments

  • I can't exactly tell - it's not actually saying what the 404 file is - just that it can't find a file when I try to post.

    as an aside....

    you should be able to see this in your apache logs

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭

    Sure, but... .htaccess hasn't been "right", basically, ever, and it's been working fine.

  • DoyceTDoyceT Model Questioner ✭✭✭

    Update:

    New discussions can be posted without error.

    Private messages can be replied to.

    Only comments to existing discussions throw the 404.

  • peregrineperegrine MVP
    edited September 2014

    Only comments to existing discussions throw the 404.

    do you see js errors anywhere.

    and check your apache errorlog.

    you could also try disabling all your plugins and see if you get error.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited September 2014

    .

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭
    edited September 2014

    I updated the 404 file to kick out the requested URL.

    Then, tried to post a reply to http://nila.edu/orca/discussion/699/

    And the 404 after hitting post was generated for /orca/vanilla/post/comment/?discussionid=699

    ... and then I looked at that and said "Why the fuck is it trying to go into a Vanilla subdirectory?"

    And sure enough, there's an empty Vanilla directory (from when I expanded the archive of 2.1.3 at some point) with nothing in it but an .htaccess file.

    Son of a...

    Deleted said directory, error goes away.

  • peregrineperegrine MVP
    edited September 2014

    :smiley:

    so you solved it! I take.

    so, it was .htaccess after all?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited September 2014

    sometimes copying doesn't copy hidden files e.g. with the dot. .htaccess

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭

    @peregrine said:
    so, it was .htaccess after all?

    It was .htaccess - in that there was an .htaccess in a subdirectory under the main vanilla folder that was being read instead of the proper one. Yeeesh. Tricky.

  • LincLinc Detroit Admin

    Congrats; tricky bug. Sorry about the panic, that's never fun. Rest assured, the effort was worth it. There were some mean security issues you just patched.

  • DoyceTDoyceT Model Questioner ✭✭✭

    No problem: every issue like this is an opportunity to

    1. Learn
    2. Mix exciting new cocktails to combat the panic :)

    Now I just need to figure out what plugin is overriding the config setting where I try to order posts by creation rather than modification date.

  • peregrineperegrine MVP
    edited September 2014

    @Linc and @hgtonight.

    because if your forum was not > @Linc said:

    It's possible a plugin is overriding your Vanilla.Discussions.SortField.

    Are you guys certain the Get method gets acted upon the GetWhere doesn't override it.

    GetWhere always sorts by....

    I see that the ->OrderBy('d.DateLastComment', 'desc')

    I don't see how the sort could possibly work. with the config. maybe just me though :)

    don't think it works as expected in 2.1

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I can also do this

    $Configuration['Vanilla']['Discussions']['SortField'] = 'boo';

    • one would think an error would appear it doesn't.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭
    edited September 2014

    Yeah, there's actually a line in the core that specifically looks for weird sortfields like that, so it can generate an error.

    Lines 231 to 235 in class.discussionmodel.php

  • peregrineperegrine MVP
    edited September 2014

    @Linc and @hgtonight.

    because if your forum was not > @Linc said:

    It's possible a plugin is overriding your Vanilla.Discussions.SortField.

    the Get has the configs but

    the GetWhere has no concept of the orderby from config statments.

    GetWhere always sorts by....

    I see that the ->OrderBy('d.DateLastComment', 'desc')

    I don't see how the sort works. with the config. maybe just me though :)

    to me, this is where the control order happens

    https://github.com/vanilla/vanilla/blob/2.1/applications/vanilla/models/class.discussionmodel.php#L282

    and it the config statements are not acted upon or used here.

    I would think you would need to change it to

    $this->EventArguments['SortField'] = C('Vanilla.Discussions.SortField', 'd.DateLastComment');
    $this->EventArguments['SortDirection'] = C('Vanilla.Discussions.SortDirection', 'desc');

    and put variables for sort and direction in Line 282 after the configs are called.

    If my reasoning is correct I'll post on github if you want, or you can :)

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited September 2014

    2.0.18 discussionscontroller

    // Get Discussions
    $this->DiscussionData = $DiscussionModel->Get($Page, $Limit);

    2.1 discussionscontroller

    // Get Discussions
    $this->DiscussionData = $DiscussionModel->GetWhere(FALSE, $Offset, $Limit);

    https://github.com/vanilla/vanilla/issues/2083

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • DoyceTDoyceT Model Questioner ✭✭✭

    Hi all,

    Any thoughts on how I can address the issue that @peregrine has found? Is there a way to write an addon that would circumvent the change in 2.1 discussionscontroller and get the system to use my config settings?

  • Put this in a plugin:

    public function DiscussionModel_BeforeGet_Handler($Sender) {
        $Wheres = $Sender->EventArguments['Wheres'];
        if (!array_key_exists('d.CategoryID', $Wheres) || $Wheres['d.CategoryID'][0] != ID_OF_CATEGORY_YOU_WANT_TO_SORT)
            return;
        $Sender->EventArguments['SortField'] = 'd.DateInserted';
        $Sender->EventArguments['SortDirection'] = 'desc';
    }
    
  • Just read in your first post you want to sort everything by creation.
    In that case you can just omit the second condition on line 3:

    if (!array_key_exists('d.CategoryID', $Wheres))
    

    oh and credits go to @hgtonight for this, I took it from my NillaBlog fork, but I probably got it from BlanderBlog in the first place :)

  • DoyceTDoyceT Model Questioner ✭✭✭

    MAN this is a stubborn issue.

    This is the plugin I set up - it enables just fine.

    <?php if (!defined('APPLICATION')) exit();
      $PluginInfo['OrderByCreationDate'] = array(
       'Name' => 'Order By Creation Date',
       'Description' => 'This plugin causes all posts in the forum to show up in the order in which they were originally posted, rather than ordered by most recent comment.',
       'Version' => '0.1',
       'Author' => "doycet",
       'AuthorEmail' => 'doyce.testerman@gmail.com',
       'AuthorUrl' => 'http://vanillaforums.org/discussion/comment/215804'
    );
    
    
    class OrderByCreationDatePlugin extends Gdn_Plugin {
    
    public function DiscussionModel_BeforeGet_Handler($Sender) {
        $Wheres = $Sender->EventArguments['Wheres'];
        if (!array_key_exists('d.CategoryID', $Wheres))
        return;
        $Sender->EventArguments['SortField'] = 'd.DateInserted';
        $Sender->EventArguments['SortDirection'] = 'desc';
        }
    }
    

    It doesn't seem to have any effect on the forum's list of posts at all, in any subforum.

    I have the following plugins installed:

    • Add Text to Box
    • All Viewed
    • AutoBookmark
    • BetterNotifications
    • Button Bar
    • Custom Homepage
    • FileUpload
    • In This Discussion
    • Last Edited
    • MarkdownMarkup (forces Markdown to honor soft line breaks)
    • Profile Extender
    • Quotes
    • Signatures
    • Sprites
    • UnreadDiscussion
    • Vanilla Statistics
Sign In or Register to comment.