1

For some of the extremely static content on my site, I use caching to prevent multiple db queries during every single load. I also have multiple locale on my site with custom cache key names. The actual execution of cache is running perfectly at the moment on all the locales.

However, when I make changes to any entry which has cache enabled, I get stale template delete failed error. When I take look at the actual MySQL table, I see that the requisite cache row is deleted from the table upon making changes to an entry. So I don't quite understand why this error shows up.

Here is a typical cache directive I used in my templates

 {% cache globally using key  "www-features" for 24 hours %}

When I look at the runtime logs, I see following error which I am assuming it to be associated with this problem

2018/11/03 19:10:42 [error] [application] Encountered an error running task 17 (DeleteStaleTemplateCaches), step 13 of 29: An exception was thrown: CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'dateCreated' in order clause is ambiguous. The SQL statement executed was: SELECT elements.id, entries.sectionId, entries.typeId, entries.authorId, entries.postDate, entries.expiryDate FROM craft_elements elements JOIN craft_elements_i18n elements_i18n ON elements_i18n.elementId = elements.id JOIN craft_content content ON content.elementId = elements.id JOIN craft_entries entries ON entries.id = elements.id JOIN craft_sections sections ON sections.id = entries.sectionId LEFT JOIN craft_structures structures ON structures.id = sections.structureId LEFT JOIN craft_structureelements structureelements ON (structureelements.structureId = structures.id) AND (structureelements.elementId = entries.id) WHERE ((((elements_i18n.locale = :locale) AND (content.locale = :locale)) AND (elements.archived = 0)) AND (elements_i18n.enabled = 1)) AND (sections.handle IN ('policies')) GROUP BY elements.id ORDER BY dateCreated. Bound with :locale='en_us'

Looks like you have dateCreated field in multiple tables used in the join and the statement is not explicitly defining the identity of the table ???

Can anyone help me to fix this?

2

OK, I found the answer to this. Here is the correct answer.

Basically change dateCreated to elements.dateCreated in my template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.