Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1

Yaga 1.1 - Use of `url` function in BadgeAwardModel::Award is resulting in incorrect URLs

Hi all, I just upgraded my version of Yaga to 1.1, and noticed that some badge image paths were broken in activities & notifications.

Digging deeper, I noticed that in BadgeAwardModel::Award the badge image path set for the activity was changed from $Badge->Photo to Url($Badge->Photo, TRUE).

As I issue some badges outside of the Vanilla directory, I think that Url($Badge->Photo, TRUE) is messing up the image paths. If I change it to Url($Badge->Photo, FALSE) it works fine though.

However, I don't really want to be editing core files - is there another way?

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    The most obvious way would be to put your badges into your Vanilla folder but if that would be a possibility, I guess you would already done so.

    Maybe you could create a symlink in your Vanilla folder?

    Another solution would be to create a rewrite rule and add that in your .htaccess file.
    The .htaccess file is an exception. Although it is a core file, sometimes it cannot be avoided that you have to change it. That's why you should always backup that file when you update.

    pavsid
  • Hi @R_J - the badges are already in the Vanilla folder e.g. /community/imgs/badges/1.jpg - I may have confused matters - when I say " I issue some badges outside of the Vanilla directory" I mean they are issued outside of the Vanilla application (from within the main website code), and so the request URL doesn't contain /community. The url function returns the absolute URL path to the image, and if the current request is not inside the Vanilla directory it returns http://www.example.com/imgs/badges/1.jpg rather than http://www.example.com/community/imgs/badges/1.jpg.

    Contrary to what I said above Url($Badge->Photo, FALSE) doesn't actually work - it messes badges up which are issued within the Vanilla application i.e. it returns /community/imgs/badges/1.jpg which then gets rendered as /community/community/imgs/badges/1.jpg...!

    It would have been better to not use the url function at all, as in the previous version.

    .htaccess is a good suggestion. I can create a rule to detect imgs/badges/... and rewrite to /community/imgs/badges/... - thanks ;)

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Not sure, but maybe the function smartAsset() would work. Would you mind to try that out and if it works with smartAsset, give feedback to hgtonight?

  • Hi @R_J and @hgtonight - tested both smartAsset($path, TRUE) and smartAsset($path, FALSE) and it seemed to do exactly the same as url($path, TRUE) and url($path, FALSE) respectively.

    I have used @R_J 's suggestion of .htaccess rules to redirect any broken links appropriately - thanks!

Sign In or Register to comment.