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

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'))
 
@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.webp

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
 
I couldn't really answer that. It's only relevant if you are changing the version ID on templates without changing the content though.
 
I couldn't really answer that. It's only relevant if you are changing the version ID on templates without changing the content though.

Ah, that wouldn't be the case then. Did anything change with the template update process with 1.5?
 
@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?
 
@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).
 
@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).
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.
 
Hmm so you edit the .XML file back out forward?
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.
 
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.
Thanks a lot, Arty! Very helpful.
 
Back
Top Bottom