1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed last_edit_date is not updated for templates when newer version is imported

Discussion in 'Resolved Bug Reports' started by Arty, Aug 25, 2015.

  1. Arty

    Arty Well-Known Member

    When importing style, if template's version_id has changed, but content hasn't changed, XenForo doesn't update last_edit_date of that template and shows it as outdated.

    That happens very often when updating style for latest version of XenForo or any add-on - sometimes there is nothing to change in template other than bumping version number.

    Issue is caused by template data writer. It updates last_edit_date only if template content was changed, ignoring changes to other properties. I think it should update last_edit_date when version_id is updated as well.

    Fix: in library/XenForo/DataWriter/Template.php find
    Code:
        if ($this->isChanged('template') && !$this->isChanged('last_edit_date'))
    
    replace with
    Code:
        if (($this->isChanged('template') || $this->isChanged('version_id')) && !$this->isChanged('last_edit_date'))
    
     
  2. Mike Creuzer

    Mike Creuzer Well-Known Member

    Arty likes this.
  3. dethfire

    dethfire Well-Known Member

    This happens a lot to me
     
  4. Mike

    Mike XenForo Developer Staff Member

    I've adjusted this now, thanks.
     
    Arty and dethfire like this.
  5. Jake B.

    Jake B. Well-Known Member

    @Mike Any word on whether this was the cause of the issue I had reported here? We've never had this issue until 1.5.

    Screenshot from outdated template list on our theme demo:


    outdated.png

    None of these are actually outdated, and we updated to XF 1.5 before we updated the themes but it's still saying that over 100 templates are outdated
     
  6. Mike

    Mike XenForo Developer Staff Member

    I couldn't really answer that. It's only relevant if you are changing the version ID on templates without changing the content though.
     
  7. Jake B.

    Jake B. Well-Known Member

    Ah, that wouldn't be the case then. Did anything change with the template update process with 1.5?
     
  8. Arty

    Arty Well-Known Member

    @Jake B. Maybe you've updated templates on demo before updating XenForo? That would result in outdated template notices as well.
     
  9. Jake B.

    Jake B. Well-Known Member

    Nope :\

     
  10. Mike

    Mike XenForo Developer Staff Member

    No. I don't think there has been any change to the feature since it was first introduced.
     
  11. isaacl

    isaacl Member

    @Mike - Any ETA for when this will be released?
    Thanks!
     
  12. Mike

    Mike XenForo Developer Staff Member

    It will be in 1.5.1, but there is not an explicit date for that.
     
  13. isaacl

    isaacl Member

    OK, looking forward, thanks!
     
  14. Mike Creuzer

    Mike Creuzer Well-Known Member

    @Mike I am still getting outdated templates for xenmedia gallery/rm as well as any other third-party add-on in which a template has been edited in the theme.

    Now technically it might be correct depending on install order. If you upgrade your add-ons after you install the theme, I believe these messages will still stick around. But for me, it happens regardless of order. I could be wrong, its a bit hard to be sure.

    Is there a way to fix this?
     
  15. Arty

    Arty Well-Known Member

    @Mike Creuzer I've solved that issue by bumping version numbers of all templates in xml file to latest supported version.

    It doesn't break version check because version number points to latest version, so newer version of add-on will show outdated templates correctly. It does create an easy solution for invalid outdated templates notices that appear when add-on is updated after style: install older xml (changes version numbers to previous version), install newer xml again (changes version numbers to current version and bumps last_edit_date, getting rid of all incorrect notices).
     
  16. Mike Creuzer

    Mike Creuzer Well-Known Member

    Hmm so you edit the .XML file back out forward? Like some of the templates in the add-on never need to be updated cause they do not change. I think not only should a check be made on version history but also offer there was a change at all. If no change then it's not outdated. You would think merging would do that but all of these cannot be merged.
     
  17. Arty

    Arty Well-Known Member

    Something like that. Script checks for latest versions of each add-on in style XML file, including XenForo, replaces template versions in templates that were modified in older version.

    So for example, for XF 1.5.1 style if there are entries in XML like these:
    Code:
    <template title="account_avatar_overlay.css" addon_id="XenForo" version_id="1050170" version_string="1.5.1" disable_modifications="0">
    template stuff
    </template>
    <template title="account_two_step.css" addon_id="XenForo" version_id="1050070" version_string="1.5.0" disable_modifications="0">
    template stuff
    </template>
    it is changed to
    Code:
    <template title="account_avatar_overlay.css" addon_id="XenForo" version_id="1050170" version_string="1.5.1" disable_modifications="0">
    template stuff
    </template>
    <template title="account_two_step.css" addon_id="XenForo" version_id="1050170" version_string="1.5.1" disable_modifications="0">
    template stuff
    </template>
    As for merging, I've never seen it work on anything other than default style, so bumping template version numbers in XML file doesn't change anything.
     
    Mike Creuzer likes this.
  18. Mike Creuzer

    Mike Creuzer Well-Known Member

    Thanks a lot, Arty! Very helpful.
     

Share This Page