Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

AJAX doesn't include extensions! why? suggestion

klipklip New
edited December 2007 in Vanilla 1.0 Help
Excerpt from: appg/init_ajax.php:// INCLUDE EXTENSIONS // 2006-06-16 - Extensions are no long included here because bad extensions were causing standard ajax features to break. // include($Configuration['APPLICATION_PATH'].'conf/extensions.php');
I don't understand this :/
I've just spent three hours by trying to "AddToDelegate( 'ExtensionForm', 'PreExtensionDisable', ..." and finding out why it is not working!

What was exactly the problem with bad extensions? IMHO It is problem of extension developer.
Maybe we should prohibit all extensions at all, because bad extensions causes standard features to break.
We can also prohibit knifes because bad people are causing death to innocent people :)

My extension needs to do cleanup when it is disabled. I'm sure I can find some other way, but it won't be nice and would cause performance issues.
I'm not going to use any core hacks. They are for geeks, not for ordinary users.


If this is not going to be changed I would suggest to change the code above to:
// INCLUDE EXTENSIONS // Extensions are no long included here by default because bad extensions were causing standard ajax features to break. if ($Configuration['INCLUDE_EXTENSIONS_BY_AJAX']) { include($Configuration['APPLICATION_PATH'].'conf/extensions.php'); } so user or add-on can turn including on

or maybe better:
// INCLUDE EXTENSIONS // Extensions are no long included here by default because bad extensions were causing standard ajax features to break. // use /path/to/vanilla/conf/ajax_extensions.php @include($Configuration['APPLICATION_PATH'].'conf/ajax_extensions.php'); so extension can install itself to be included by ajax

Comments

  • Options
    Assuming that the cause of the breakage was an extension outputting something to the browser before the Ajax script could do its thing, another possible fix would be to dump the output buffer after the include.

    This, coincidentally, is done to solve a related problem in init_vanilla.php. Problem is, in init_vanilla.php It's run before the extensions are included... which has benefits that you can easily output debug info from an extension, but the downside that a little white space at the end of a ?> can break the doctype and page validation.

    For other reasons there should be extensions in init_ajax--I once tried saving all extensions to some other path on the server, but the ajax calls on those extensions were all directed to the assumed extension path & extension folder. It would be nice to have a generic ajax page like the extension.php page that we can direct all extension ajax calls to. (now I'm just rambling...)

    Back to the issue at hand, a buffer clear in init_ajax is desirable, but should the one in init_vanilla also be moved to after the extensions are loaded?
  • Options
    WallPhoneAssuming that the cause of the breakage was an extension outputting something to the browser before the Ajax script could do its thing
    I have installed these addons:
    MultiRoles, Legends, IpHistory, FeedPublisher, Statistics, HideSuccess, MarkAllRead, YellowFade, SubCategories, RoleHistory, JQuery, Attachments, ConfirmGoBack, FixLanguageDefinitions, ParticipatedThreads, UserTasks, ReportPost, CommentLinks, CleverEdit, FeedReader, InlineImages, Mary, NewApplicants, PrivateAccounts, Textile, PreviewPost, ContactForm, LanguageSelector, GuestSignIn, GuestPost, HtmlFormatter, CategoryRoles, AddMember,
    CategoryJumper, Notify

    So far only Notify was causing problem, which I could easily fix and I reported it. Problem was it was using using $Head object which is not created by init_ajax but it was bug because there were missing block brackets for if command, so it caused to use $Head object anytime not only if SelfURL is of certain value.

    Haven't met yet any which would cause ajax to be broken by output
    This, coincidentally, is done to solve a related problem in init_vanilla.php. Problem is, in init_vanilla.php It's run before the extensions are included... which has benefits that you can easily output debug info from an extension, but the downside that a little white space at the end of a ?> can break the doctype and page validation.
    Still I think that extension developer should be responsible for its extensions. I personally don't use ?> at all at the end of php file. So it can never add white space after ?> (because it's just missing :-)
    I use debugging in ajax (if I enable extensions in ajax), which breaks the functionallity of it but it displays me dumps.
    If there would be buffer clean after calling extensions you can always use $Context->WarningCollector->Add( 'Debug message' ) (not sure due ajax, but normal calls are ok with this)

    Anyway, still I'm thinking it would be the safest solution to have empty conf/ajax_extensions.php as default and only extensions needed to be called by ajax can add themselves there. Developer of such extension would probably know what he is doing and won't break ajax.

    But whatever solution which allows the extension to be called by ajax is welcome! Buffer cleaning sounds fine for me either, if it is ok for others :-)
This discussion has been closed.