Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.
Please upgrade here. These earlier versions are no longer being updated and have security issues.

SphinxSearch Plugin Conflicts with Quotes Plugin

ShadowdareShadowdare Moderator
edited December 2013 in Vanilla 2.0 - 2.8
This discussion was created from comments split from: Drop in recplacement?.

Add Pages to Vanilla with the Basic Pages app

Comments

  • meshugymeshugy Musician/Hacker ✭✭

    Has anyone else had problems running Sphinx along with the Quotes plugin in Vanilla 2.1b2? I've tried everything I can think of, including disabling all other plugins, clearing the cache, etc. No matter what I do, the Quotes plugin refuses to copy quoted text into the editor when Sphinx is enabled. Any ideas on how to fix this?

  • ShadowdareShadowdare Moderator
    edited December 2013

    @meshugy, I guess that there's a JavaScript (JS) conflict with the Sphinx plugin's JS code and Quotes plugin's JS code. Please open the console of your web browser (Firefox Guide / Chrome Guide), refresh the page, and try quoting a post, then see if any errors show up in the console.

    Add Pages to Vanilla with the Basic Pages app

  • meshugymeshugy Musician/Hacker ✭✭

    @Shadowdare I took a look at that the console. It only showed CSS warnings. It didn't mention any JS errors.

  • ShadowdareShadowdare Moderator
    edited December 2013

    @meshugy, what version of the Quotes plugin are you using? If it's older than version 1.6.7, please try the one in the GitHub development repo: https://github.com/vanillaforums/Addons/tree/master/plugins/Quotes

    Add Pages to Vanilla with the Basic Pages app

  • meshugymeshugy Musician/Hacker ✭✭
    edited December 2013

    @Shadowdare I'm using ver 1.67 which I believe is the most current version. I think at one point I tried some older versions and had the same problem.

  • meshugymeshugy Musician/Hacker ✭✭

    I just tried switching back to Quotes ver. 1.6.1 and that seems to work fine with Sphinx so maybe I'll keep using that for a while.

  • ShadowdareShadowdare Moderator
    edited January 2014

    @meshugy, it's also strange that disabling Sphinx fixes the quoting problem. It's good to know that switching back to Quotes 1.6.1 fixes it.

    For others who may run into the same problem with Quotes 1.6.7 and would like to debug it, here is some info on what to look for:

    • There are two main ways that the quote link for a post works. The first way is if JS is enabled in the browser, it will retrieve the text to be quoted with AJAX through the /discussion/getquote/ method, and output that to the new comment text box.

    • The second way is if JS is disabled, the quote link will redirect to the /post/quote/ page.

    One would have to find out which stage of the procedure the quoting functionality stops working and why disabling the Sphinx plugin fixes it.

    Add Pages to Vanilla with the Basic Pages app

  • meshugymeshugy Musician/Hacker ✭✭

    @Shadowdare said:
    meshugy, it's also strange that disabling Sphinx fixes the quoting problem. It's good to know that switching back to Quotes 1.6.1 fixes it.

    However, Quotes 1.6.1 has some formatting problems (it doesn't show the quote author's name) so I'll be switching back to 1.6.7. I'll see if I can give you more info about why Sphinx is interfering with the Quotes plugin.

    Shadowdare
  • meshugymeshugy Musician/Hacker ✭✭
    edited December 2013

    @Shadowdare I disabled javascript in my browser and that allowed quotes 1.6.7 to work with Sphinx. I hope this gives you some sense of what may be wrong.

  • ShadowdareShadowdare Moderator
    edited December 2013

    @meshugy, I just installed the Sphinx plugin and Quotes 1.6.7 on my test server with Vanilla 2.1b2 and I get the same problem as you do, but when I have the web browser console open and click a quote link several times, an error comes up with GET - http://example.com/discussion/getquote/Discussion_2?format=Html - 400 (Bad Request).

    When I click on the link in the error, I get a page with "Code": 400, "Exception": "DiscussionController->Discussion not found." along with a stack trace, but this is probably happening for me as I haven't configured the Sphinx plugin completely since this is a test server.

    Does the error also come up for you in the console if you click on a quote link more than once? If so, what do you get if you go to the link in the error?

    Add Pages to Vanilla with the Basic Pages app

  • meshugymeshugy Musician/Hacker ✭✭

    I just tried again ( I think the JS error reporting wasn't on the first time I tried.) I received these errors:

    15:08:40.717 Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. jquery.min.js:3
    15:08:40.724 Use of Mutation Events is deprecated. Use MutationObserver instead.
    
  • meshugymeshugy Musician/Hacker ✭✭

    Perhaps this is the solution?

    http://stackoverflow.com/questions/19372658/jquery-1-10-2-warning-issue-from-firefox

    There's a bug in jQuery. I'd try the fix above but I don't know where event.js is. Any clues?

  • ShadowdareShadowdare Moderator
    edited December 2013

    I think those two errors aren't related to the Quotes problem. The depreciated error just means that those functions will be removed in a future version of JQuery, so they should still work at the moment.

    What happens if you go to the http://EXAMPLE.com/discussion/getquote/Discussion_#?format=Html page? Replace EXAMPLE.com with the path to your forum, and also replace # with any discussion's ID number, which can be found in their URLs.

    Add Pages to Vanilla with the Basic Pages app

  • meshugymeshugy Musician/Hacker ✭✭

    I entered this link:

    http://www.djangobooks.com/forum/discussion/getquote/Disucussion_12618?format=Html

    The regular browser returned:

    {"Code":400,"Exception":"DiscussionController->Discussion not found.","Class":"Exception"}
    

    The console reported this error:


  • meshugymeshugy Musician/Hacker ✭✭

    I just noticed that Sphinx also prevents comment sharing with my WordPress blog. I'm using Vanilla for all the comments on my blog and when Sphinx is enabled, the comment box will not display in WordPress posts.

  • ShadowdareShadowdare Moderator
    edited January 2014

    Thanks for posting the error you got from the page. We got the same error, so this means that the error can be reproduced and other people will run into the same problem with the Quotes plugin version 1.6.7. I looked into it further and have a solution.

    Explanation

    The SphinxSearch plugin (version 20131210) has a Related Discussions widget that shows up on all pages of DiscussionController. The problem occurs at line 69 and 70 of the /plugins/SphinxSearch/widgets/class.widget.relateddiscussion.php file with these lines of code:

    $Thread = $this->SphinxClient->EscapeString($Sender->Discussion->Name); //get the discussion name (thread topic) to search against
    $Query = $this->FieldSearch($this->OperatorOrSearch($Thread), array(SS_FIELD_TITLE));
    

    The FieldSearch method requires a valid discussion name and uses the $Thread variable to get it. The discussion name is assigned to this variable by the $Sender->Discussion->Name property.

    The reason that Quotes 1.6.1 works is because it retrieves quotes through the /plugin/quotes/getquote/ method in PluginController in which SphinxSearch's Related Discussions widget isn't being loaded. With Quotes 1.6.7, the GetQuote method has been moved to DiscussionController, and doesn't pass along the data about the discussion, so the $Sender->Discussion object isn't declared at all in that method. This is why the problem comes up.

    In summary, because SphinxSearch tries to load up its Related Discussions widget through an event handler that is loaded in all methods of the DiscussionController and tries to retrieve the discussion name with $Sender->Discussion->Name, it errors out because that property and the $Sender->Discussion object doesn't exist.

    Solution

    The solution is to open the the /plugins/SphinxSearch/widgets/class.widget.relateddiscussion.php file and go to line 59 that says:

            if ($Sender->ControllerName == 'discussioncontroller') {
    

    And change that to:

            if ($Sender->ControllerName == 'discussioncontroller' && isset($Sender->Discussion)) {
    

    I'm not sure if this modification will break some functionality of SphinxSearch, but there are different ways to fix this problem, and this will fix the quotes problem for sure. Please let me know if it works for you.

    Add Pages to Vanilla with the Basic Pages app

    peregrinemeshugyhgtonight
  • meshugymeshugy Musician/Hacker ✭✭

    @Shadowdare Success! Thanks for the fix....it appears to work perfectly now. I'll keep testing, but so far so good.

  • @meshugy, you're welcome! I'm glad it works now. Also, have a happy new year!

    Add Pages to Vanilla with the Basic Pages app

  • mcu_hqmcu_hq yippie ki-yay Arizona, USA ✭✭✭

    @Shadowdare wow, thanks for that great debug! I was unaware of Quotes 1.6.7. My version of vanilla 2.1b came with 1.6.1, which worked fine. I've made the change into the code and will post an updated version

    Shadowdare
Sign In or Register to comment.