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.

Vanilla built-in filters not working

edited December 2011 in Vanilla 2.0 - 2.8

After having activated this plugin (which is very cool and handy by the way), I noticed the build in filters for replacing Youtube links with embedded videos and marking @-mentions stop working (no error msg, just as if they do not exist). As this leads to a loss of important functionality I have to deactivate your plugin until someone comes up with a solution.

I use Vanilla 2.0.18.1 and Vanilla Twitter Embed 0.2.

I have only enabled some of the default plugins: Emotify, WYSIWYG (CLEditor) and the sign-in plugins.

Tagged:

Best Answer

  • UnderDogUnderDog MVP
    edited December 2011 Answer ✓

    Kiwii said:
    I would look into this myself, but I am painfully unfamiliar with Vanilla's source and api.

    You don't have to be familiar with the source code and api to look into the problem.
    What you have to find, using a text editor that can search into files is at which moment the @-mentions are executed. It's an event that is executed.
    I think that event conflicts with the event from the twitter plugin.

    good luck

    There was an error rendering this rich post.

Answers

  • 422422 Developer MVP

    Could be one of the sign in plugins, have you disabled in different sequences to isolate the issue, sometimes js calls in wrong load order can affect functionality.

    There was an error rendering this rich post.

  • Having disabled all plugins but 'Twitter Embed' I am now certain that the problem relies in this plugin. To clarify my problems: Having enabled 'Twitter Embed', links to Youtube videos are no longer replaced by embedded videos. And mentions (like @Kiwii) are no longer replaced by links to the profiles. Those two filters are build into Vanilla and should not be dependent on other plugins.
    However 'Twitter Embed' itself functions exactly like it is supposed.
    I noticed this plugin being published for Vanilla 2.0.18 and I use Vanilla 2.0.18.1. Could it be possible that the plugin needs to be updated? I have not yet looked at the code myselv, but I think it is possibly a return code or similar that is interpreted by Vanilla in the way that default text replacements are not to be executed (Vanilla may think the plugin completely displaces them).

    Thank you for caring :D

  • 422422 Developer MVP

    Have you opened firebug and looked at Dom Events ?

    There was an error rendering this rich post.

  • @422 not yet as I am not on my production pc; but I do not think that it is a client side problem, as the replacement of username mentions with links to the user's profile is not dependent on javascript (works with js disabled). I think the problem relies at the server's side in the php code.

  • 422422 Developer MVP

    If you are referring to twitter embed its fair to assume it could simply be an id collision

    There was an error rendering this rich post.

  • No Vanilla plugins & Javascript disabled -> Mentions & Youtube videos working.
    Only 'Twitter Embed' in Vanilla & Javascript disabled -> Mentions & Youtube videos not working.

    My problem has nothing to do with javascript or anything client-side. The server-side php code that should replace @nickname mentions and youtube links (and which is part of Vanilla) is just not executed if the plugin 'Twitter Embed' is enabled. Because this plugin hooks into the server-sided post parsing I believe it somehow makes Vanilla not execute it's own parsing methods. As this problems would have been noticed on the first release of this plugin, I assume the problem is caused by the Vanilla update '2.0.18->2.0.18.1'. It's either a change in the api or simply a bug.

    I would look into this myself, but I am painfully unfamiliar with Vanilla's source and api.

  • UnderDogUnderDog MVP
    edited December 2011 Answer ✓

    Kiwii said:
    I would look into this myself, but I am painfully unfamiliar with Vanilla's source and api.

    You don't have to be familiar with the source code and api to look into the problem.
    What you have to find, using a text editor that can search into files is at which moment the @-mentions are executed. It's an event that is executed.
    I think that event conflicts with the event from the twitter plugin.

    good luck

    There was an error rendering this rich post.

  • Okay, I think I begin to understand the problem:

    from VanillaTwitterEmbed/class.vanillatwitterembed.plugin.php, ll. 123-130:
    // Setup the callback for every page that handles comments to a post.
    public function Base_AfterCommentFormat_Handler ( &$Sender )
    {
        $Object = $Sender->EventArguments['Object'];``
        $Object->FormatBody = $this->TwitterEmbed($Object->Body);
        $Sender->EventArguments['Object'] = $Object;
    }
    

    The 'Twitter Embed' plugin gets the unformatted post content $Object->Body, does it's own filtering TwitterEmbed(..); and overwrites the already formatted (by the core) content with it's formatted version. $Object->FormatBody = $this->...
    Because the replacement of @-Mentions and Youtube links is done before this, there is already formatted content in the $Object->FormatBody variable.

    However changing the line to

    $Object->FormatBody = $this->TwitterEmbed($Object->FormatBody);
    

    fixes the problem but creates a new one, too: The @username mentions and youtube links are working fine now and twitter links are replaced by embedded tweets, but above each Tweet, the content of the Tweet is replicated. This happens because the regex has to be rewritten to understand the formatted links instead of unformatted links. Well, I try to look into this, but I am not very used to regexes.

  • Yeah, my new Regex looks like that:

    '/<a href="(http|https)\:\/\/twitter.com\/(.*?)\/status\/([0-9]+)" target="_blank" rel="nofollow">(http|https)\:\/\/twitter.com\/(.*?)\/status\/([0-9]+)<\/a>/';
    

    And now, the plugin works like I expected it to without interfering with Vanilla's core features.

    If anyone is interested in this, I uploaded the modified version of VanillaTwitterEmbed/class.vanillatwitterembed.plugin.php to Pastebin but I do not know if this works with every Vanilla installation and I do not give any guaranty.

  • If I could give out developer badges, I would give one to you right now. Excellent work!

    Maybe a new version of the plugin could be uploaded. I'll alert @JamieChung if he wants to do it.

    There was an error rendering this rich post.

  • Thanks everyone for looking at this. @Kiwii @UnderDog @422

    I'm reviewing everything now and publishing an updated version. Good catch especially @Kiwii!

  • edited December 2011

    The plugin has been updated to 0.3

    Official changes made on Github: https://github.com/JamieChung/VanillaTwitterEmbed/commit/a9e345c82420458b7156979534bde4bec30b982c

    Thanks again guys, I am glad people are finding use of the addon I made.

Sign In or Register to comment.