Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-24154

Overriding template with section_identifier fails when cached

    Details

      Description

      If a template is declared to override using the match by section_identifier, and the view cache is enabled, the cached versions will fall back to default templates and ignore the overrides.

      test case:
      1 - setting up the environment

      • enable debug and list templates options in admin
      • create a section called "test" (name and identifier)
      • create a folder X, set the section to "test"
      • assign anonymous user permissions to read section "test"
      • open X in frontend
      • check the full path of the "pagelayout.tpl" used, to override it. it will depend on the extension used to generate the frontend (ezflow, ezdemo, etc)

      2 - making the override

      • edit the "pagelayout.tpl" file with some change, save it at the path <extension>/overrides/templates/modified_pagelayout.tpl
      • add to the default frontend siteaccess settings/override.ini.append.php:

          [pagelayout_section_test]
          Source=pagelayout.tpl
          MatchFile=modified_pagelayout.tpl
          Subdir=templates
          Match[section_identifier]=test
        

      • clear all caches
      • open X in frontend. the modified_pagelayout.tpl is used, at bottom of debug it can be checked the correct usage.
      • reload the page, view falls back to default template. the debug at bottom shows that none of the templates are overriden.

        Activity

        Hide
        André Rømcke added a comment - - edited

        Not saying the bug is non existing, but the example seems to be wrong:
        https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-override-conditions

        To match on section identifier you need to match using "section_identifier".
        Could you please retest with the correct match condition?

        Show
        André Rømcke added a comment - - edited Not saying the bug is non existing, but the example seems to be wrong: https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-override-conditions To match on section identifier you need to match using "section_identifier". Could you please retest with the correct match condition?
        Hide
        Paulo Bras (Inactive) added a comment -

        André Rømcke ,
        yes, the docs show only "section", but the test was done with both values "section" and "section_identifier". the result is exactly the same, so the value is not important.

        the test case uses the "section" value, since it's the value used in the documentation. when the issue is solved, the documentation should be updated as part of the solution too.

        Show
        Paulo Bras (Inactive) added a comment - André Rømcke , yes, the docs show only "section", but the test was done with both values "section" and "section_identifier". the result is exactly the same, so the value is not important. the test case uses the "section" value, since it's the value used in the documentation. when the issue is solved, the documentation should be updated as part of the solution too.
        Hide
        Artur Wawrzynkiewicz added a comment -

        tested with multiple combinations of section (id / identifier value) and section_identifier, same result
        override does work w/o viewcache, override does not work with viewcache enabled

        Show
        Artur Wawrzynkiewicz added a comment - tested with multiple combinations of section (id / identifier value) and section_identifier, same result override does work w/o viewcache, override does not work with viewcache enabled
        Hide
        André Rømcke added a comment - - edited

        Artur Wawrzynkiewicz and Paulo Bras I can not see why the section override does not work, if some of you can try the following patch to provide some debug please:

        diff --git a/kernel/classes/eznodeviewfunctions.php b/kernel/classes/eznodeviewfunctions.php
        index c9a849a..dff940c 100644
        --- a/kernel/classes/eznodeviewfunctions.php
        +++ b/kernel/classes/eznodeviewfunctions.php
        @@ -513,6 +513,7 @@ class eZNodeviewfunctions
                                            array( 'state', $Result['content_info']['state'] ),
                                            array( 'state_identifier', $Result['content_info']['state_identifier'] ),
                                            array( 'section', $Result['section_id'] ) );
        +var_dump( $Result['section_id'] );
         
                         if ( isset( $Result['content_info']['class_identifier'] ) )
                             $keyArray[] = array( 'class_identifier', $Result['content_info']['class_identifier'] );
        

        `section_identifer` however I found an issue with, created PR here: https://github.com/ezsystems/ezpublish-legacy/pull/1151

        Show
        André Rømcke added a comment - - edited Artur Wawrzynkiewicz and Paulo Bras I can not see why the section override does not work, if some of you can try the following patch to provide some debug please: diff --git a/kernel/classes/eznodeviewfunctions.php b/kernel/classes/eznodeviewfunctions.php index c9a849a..dff940c 100644 --- a/kernel/classes/eznodeviewfunctions.php +++ b/kernel/classes/eznodeviewfunctions.php @@ -513,6 +513,7 @@ class eZNodeviewfunctions array( 'state', $Result['content_info']['state'] ), array( 'state_identifier', $Result['content_info']['state_identifier'] ), array( 'section', $Result['section_id'] ) ); +var_dump( $Result['section_id'] ); if ( isset( $Result['content_info']['class_identifier'] ) ) $keyArray[] = array( 'class_identifier', $Result['content_info']['class_identifier'] ); `section_identifer` however I found an issue with, created PR here: https://github.com/ezsystems/ezpublish-legacy/pull/1151
        Hide
        Artur Wawrzynkiewicz added a comment -

        in the case of cached result the value is set to "7" (section ID)
        in the case of un-cached result the value is set to "TEST" (in big characters, the identifier is small characters?!)

        This would explain why the override only works in one case, based on the differentiating key value.

        Show
        Artur Wawrzynkiewicz added a comment - in the case of cached result the value is set to "7" (section ID) in the case of un-cached result the value is set to "TEST" (in big characters, the identifier is small characters?!) This would explain why the override only works in one case, based on the differentiating key value.
        Hide
        André Rømcke added a comment - - edited

        Ok updated debug patch to get even more info then, I'm interested in the case where section_id is "TEST", this is the wrong one.

        diff --git a/kernel/classes/eznodeviewfunctions.php b/kernel/classes/eznodeviewfunctions.php
        index c9a849a..2467ffd 100644
        --- a/kernel/classes/eznodeviewfunctions.php
        +++ b/kernel/classes/eznodeviewfunctions.php
        @@ -513,6 +513,7 @@ class eZNodeviewfunctions
                                            array( 'state', $Result['content_info']['state'] ),
                                            array( 'state_identifier', $Result['content_info']['state_identifier'] ),
                                            array( 'section', $Result['section_id'] ) );
        +var_dump( $Result );
         
                         if ( isset( $Result['content_info']['class_identifier'] ) )
                             $keyArray[] = array( 'class_identifier', $Result['content_info']['class_identifier'] );
        

        It will be big, so put it in file or on gist.github.com.

        Show
        André Rømcke added a comment - - edited Ok updated debug patch to get even more info then, I'm interested in the case where section_id is "TEST", this is the wrong one. diff --git a/kernel/classes/eznodeviewfunctions.php b/kernel/classes/eznodeviewfunctions.php index c9a849a..2467ffd 100644 --- a/kernel/classes/eznodeviewfunctions.php +++ b/kernel/classes/eznodeviewfunctions.php @@ -513,6 +513,7 @@ class eZNodeviewfunctions array( 'state', $Result['content_info']['state'] ), array( 'state_identifier', $Result['content_info']['state_identifier'] ), array( 'section', $Result['section_id'] ) ); +var_dump( $Result ); if ( isset( $Result['content_info']['class_identifier'] ) ) $keyArray[] = array( 'class_identifier', $Result['content_info']['class_identifier'] ); It will be big, so put it in file or on gist.github.com.
        Hide
        Artur Wawrzynkiewicz added a comment -

        I have yset up a clean 4.7EE for my test, i do not need to test on a customer env. So should be reproducible for you too.

        Output is:
        " ["view_parameters"]=> array(5)

        { ["offset"]=> bool(false) ["year"]=> bool(false) ["month"]=> bool(false) ["day"]=> bool(false) ["namefilter"]=> bool(false) }

        ["path"]=> array(2) { [0]=> array(4)

        { ["text"]=> string(4) "Home" ["url"]=> string(20) "/content/view/full/2" ["url_alias"]=> string(0) "" ["node_id"]=> string(1) "2" } [1]=> array(4) { ["text"]=> string(10) "Folder 123" ["url"]=> bool(false) ["url_alias"]=> bool(false) ["node_id"]=> string(3) "214" } } ["title_path"]=> array(2) { [0]=> array(4) { ["text"]=> string(4) "Home" ["url"]=> string(20) "/content/view/full/2" ["url_alias"]=> string(0) "" ["node_id"]=> string(1) "2" }

        [1]=> array(3)

        { ["text"]=> string(10) "Folder 123" ["url"]=> bool(false) ["url_alias"]=> bool(false) }

        } ["section_id"]=> string(1) "7" ["node_id"]=> string(3) "214" ["navigation_part"]=> string(23) "ezcontentnavigationpart" ["content_info"]=> array(24) { ["object_id"]=> string(3) "212" ["node_id"]=> string(3) "214" ["parent_node_id"]=> string(1) "2" ["class_id"]=> string(1) "1" ["class_identifier"]=> string(6) "folder" ["remote_id"]=> string(32) "da869b20f963bbc564470e78c7e10469" ["node_remote_id"]=> string(32) "3cc1858523e68f82c4d6fd34162a1a64" ["offset"]=> bool(false) ["viewmode"]=> string(4) "full" ["navigation_part_identifier"]=> string(23) "ezcontentnavigationpart" ["node_depth"]=> string(1) "2" ["url_alias"]=> string(10) "Folder-123" ["current_language"]=> string(6) "eng-GB" ["language_mask"]=> string(1) "3" ["main_node_id"]=> string(3) "214" ["main_node_url_alias"]=> bool(false) ["persistent_variable"]=> bool(false) ["class_group"]=> bool(false) ["state"]=> array(1)

        { [2]=> string(1) "1" }

        ["state_identifier"]=> array(1)

        { [0]=> string(18) "ez_lock/not_locked" }

        ["parent_class_id"]=> string(2) "23" ["parent_class_identifier"]=> string(9) "frontpage" ["parent_node_remote_id"]=> string(32) "f3e90596361e31d496d4026eb624c983" ["parent_object_remote_id"]=> string(32) "8a9c9c761004866fb458d89910f52bee" } ["template_list"]=> array(3)

        { [0]=> string(67) "extension/ezwebin/design/ezwebin/override/templates/full/folder.tpl" [1]=> string(60) "design/standard/templates/content/datatype/view/ezstring.tpl" [2]=> string(46) "design/standard/templates/navigator/google.tpl" }

        ["cache_ttl"]=> int(-1) }

        Show
        Artur Wawrzynkiewicz added a comment - I have yset up a clean 4.7EE for my test, i do not need to test on a customer env. So should be reproducible for you too. Output is: " ["view_parameters"] => array(5) { ["offset"]=> bool(false) ["year"]=> bool(false) ["month"]=> bool(false) ["day"]=> bool(false) ["namefilter"]=> bool(false) } ["path"] => array(2) { [0] => array(4) { ["text"]=> string(4) "Home" ["url"]=> string(20) "/content/view/full/2" ["url_alias"]=> string(0) "" ["node_id"]=> string(1) "2" } [1] => array(4) { ["text"]=> string(10) "Folder 123" ["url"]=> bool(false) ["url_alias"]=> bool(false) ["node_id"]=> string(3) "214" } } ["title_path"] => array(2) { [0] => array(4) { ["text"]=> string(4) "Home" ["url"]=> string(20) "/content/view/full/2" ["url_alias"]=> string(0) "" ["node_id"]=> string(1) "2" } [1] => array(3) { ["text"]=> string(10) "Folder 123" ["url"]=> bool(false) ["url_alias"]=> bool(false) } } ["section_id"] => string(1) "7" ["node_id"] => string(3) "214" ["navigation_part"] => string(23) "ezcontentnavigationpart" ["content_info"] => array(24) { ["object_id"] => string(3) "212" ["node_id"] => string(3) "214" ["parent_node_id"] => string(1) "2" ["class_id"] => string(1) "1" ["class_identifier"] => string(6) "folder" ["remote_id"] => string(32) "da869b20f963bbc564470e78c7e10469" ["node_remote_id"] => string(32) "3cc1858523e68f82c4d6fd34162a1a64" ["offset"] => bool(false) ["viewmode"] => string(4) "full" ["navigation_part_identifier"] => string(23) "ezcontentnavigationpart" ["node_depth"] => string(1) "2" ["url_alias"] => string(10) "Folder-123" ["current_language"] => string(6) "eng-GB" ["language_mask"] => string(1) "3" ["main_node_id"] => string(3) "214" ["main_node_url_alias"] => bool(false) ["persistent_variable"] => bool(false) ["class_group"] => bool(false) ["state"] => array(1) { [2]=> string(1) "1" } ["state_identifier"] => array(1) { [0]=> string(18) "ez_lock/not_locked" } ["parent_class_id"] => string(2) "23" ["parent_class_identifier"] => string(9) "frontpage" ["parent_node_remote_id"] => string(32) "f3e90596361e31d496d4026eb624c983" ["parent_object_remote_id"] => string(32) "8a9c9c761004866fb458d89910f52bee" } ["template_list"] => array(3) { [0]=> string(67) "extension/ezwebin/design/ezwebin/override/templates/full/folder.tpl" [1]=> string(60) "design/standard/templates/content/datatype/view/ezstring.tpl" [2]=> string(46) "design/standard/templates/navigator/google.tpl" } ["cache_ttl"] => int(-1) }
        Hide
        André Rømcke added a comment - - edited

        Thanks, however ["section_id"]=> string(1) "7" is the good results, I'm more interested in when it is "TEST".

        Show
        André Rømcke added a comment - - edited Thanks, however ["section_id"] => string(1) "7" is the good results, I'm more interested in when it is "TEST".
        Hide
        Artur Wawrzynkiewicz added a comment -

        This var_dump only occures when cached, imho it's in the function contentViewRetrieve()
        When not cached i have added additional dump of $keyArray in generateNodeViewData(), output of uncached is:

        array(17) { [0]=> array(2)

        { [0]=> string(6) "object" [1]=> string(3) "212" }

        [1]=> array(2)

        { [0]=> string(4) "node" [1]=> string(3) "214" }

        [2]=> array(2)

        { [0]=> string(11) "parent_node" [1]=> string(1) "2" }

        [3]=> array(2)

        { [0]=> string(5) "class" [1]=> string(1) "1" }

        [4]=> array(2)

        { [0]=> string(16) "class_identifier" [1]=> string(6) "folder" }

        [5]=> array(2)

        { [0]=> string(11) "view_offset" [1]=> bool(false) }

        [6]=> array(2)

        { [0]=> string(8) "viewmode" [1]=> string(4) "full" }

        [7]=> array(2)

        { [0]=> string(9) "remote_id" [1]=> string(32) "da869b20f963bbc564470e78c7e10469" }

        [8]=> array(2)

        { [0]=> string(14) "node_remote_id" [1]=> string(32) "3cc1858523e68f82c4d6fd34162a1a64" }

        [9]=> array(2)

        { [0]=> string(26) "navigation_part_identifier" [1]=> string(23) "ezcontentnavigationpart" }

        [10]=> array(2)

        { [0]=> string(5) "depth" [1]=> string(1) "2" }

        [11]=> array(2)

        { [0]=> string(9) "url_alias" [1]=> string(10) "Folder-123" }

        [12]=> array(2)

        { [0]=> string(11) "class_group" [1]=> bool(false) }

        [13]=> array(2) { [0]=> string(5) "state" [1]=> array(1)

        { [2]=> string(1) "1" }

        } [14]=> array(2) { [0]=> string(16) "state_identifier" [1]=> array(1)

        { [0]=> string(18) "ez_lock/not_locked" }

        } [15]=> array(2)

        { [0]=> string(7) "section" [1]=> string(1) "7" }

        [16]=> array(2)

        { [0]=> string(18) "section_identifier" [1]=> string(4) "test" }

        }

        which has also a good value for "section" [1]=> string(1) "7"

        I see that the String "TEST" was just a string in my override pagelayou body.

        Show
        Artur Wawrzynkiewicz added a comment - This var_dump only occures when cached, imho it's in the function contentViewRetrieve() When not cached i have added additional dump of $keyArray in generateNodeViewData(), output of uncached is: array(17) { [0] => array(2) { [0]=> string(6) "object" [1]=> string(3) "212" } [1] => array(2) { [0]=> string(4) "node" [1]=> string(3) "214" } [2] => array(2) { [0]=> string(11) "parent_node" [1]=> string(1) "2" } [3] => array(2) { [0]=> string(5) "class" [1]=> string(1) "1" } [4] => array(2) { [0]=> string(16) "class_identifier" [1]=> string(6) "folder" } [5] => array(2) { [0]=> string(11) "view_offset" [1]=> bool(false) } [6] => array(2) { [0]=> string(8) "viewmode" [1]=> string(4) "full" } [7] => array(2) { [0]=> string(9) "remote_id" [1]=> string(32) "da869b20f963bbc564470e78c7e10469" } [8] => array(2) { [0]=> string(14) "node_remote_id" [1]=> string(32) "3cc1858523e68f82c4d6fd34162a1a64" } [9] => array(2) { [0]=> string(26) "navigation_part_identifier" [1]=> string(23) "ezcontentnavigationpart" } [10] => array(2) { [0]=> string(5) "depth" [1]=> string(1) "2" } [11] => array(2) { [0]=> string(9) "url_alias" [1]=> string(10) "Folder-123" } [12] => array(2) { [0]=> string(11) "class_group" [1]=> bool(false) } [13] => array(2) { [0] => string(5) "state" [1] => array(1) { [2]=> string(1) "1" } } [14] => array(2) { [0] => string(16) "state_identifier" [1] => array(1) { [0]=> string(18) "ez_lock/not_locked" } } [15] => array(2) { [0]=> string(7) "section" [1]=> string(1) "7" } [16] => array(2) { [0]=> string(18) "section_identifier" [1]=> string(4) "test" } } which has also a good value for "section" [1] => string(1) "7" I see that the String "TEST" was just a string in my override pagelayou body.
        Hide
        André Rømcke added a comment - - edited

        Ok,

        so does that also mean pagelayout override works (cached, cached on page refresh, and uncached) with the following?

          [pagelayout_section_test]
          Source=pagelayout.tpl
          MatchFile=modified_pagelayout.tpl
          Subdir=templates
          Match[section]=7
        

        If so I'll focus on the existing section_identifier PR, otherwise I'll look into where the override keys might get reset or something.

        Show
        André Rømcke added a comment - - edited Ok, so does that also mean pagelayout override works (cached, cached on page refresh, and uncached) with the following? [pagelayout_section_test] Source=pagelayout.tpl MatchFile=modified_pagelayout.tpl Subdir=templates Match[section]=7 If so I'll focus on the existing section_identifier PR, otherwise I'll look into where the override keys might get reset or something.
        Hide
        Artur Wawrzynkiewicz added a comment -

        This works with and w/o cache:

        [pagelayout_section_test]
        Source=pagelayout.tpl
        MatchFile=pagelayout_section_test.tpl
        Subdir=templates
        Match[section]=7

        This does not work with enabled cache, but works w/o cache:

        [pagelayout_section_test]
        Source=pagelayout.tpl
        MatchFile=pagelayout_section_test.tpl
        Subdir=templates
        Match[section_identifier]=test

        So i suppose the section_identifier is not set for the cached result as cache key.

        Show
        Artur Wawrzynkiewicz added a comment - This works with and w/o cache: [pagelayout_section_test] Source=pagelayout.tpl MatchFile=pagelayout_section_test.tpl Subdir=templates Match [section] =7 This does not work with enabled cache, but works w/o cache: [pagelayout_section_test] Source=pagelayout.tpl MatchFile=pagelayout_section_test.tpl Subdir=templates Match [section_identifier] =test So i suppose the section_identifier is not set for the cached result as cache key.
        Hide
        André Rømcke added a comment -

        > So i suppose the section_identifier is not set for the cached result as cache key.

        Yes this is what I'm about to fix (and backport):
        https://github.com/ezsystems/ezpublish-legacy/pull/1151

        Thanks for all the feedback and testing, feel free to try out the patch in the pull request and comment on that there.

        Show
        André Rømcke added a comment - > So i suppose the section_identifier is not set for the cached result as cache key. Yes this is what I'm about to fix (and backport): https://github.com/ezsystems/ezpublish-legacy/pull/1151 Thanks for all the feedback and testing, feel free to try out the patch in the pull request and comment on that there.
        Show
        André Rømcke added a comment - Merged: https://github.com/ezsystems/ezpublish-legacy/commit/3882dd3dc8614f3a14aae553c561c54d384376c7
        Hide
        Rui Silva (Inactive) added a comment -

        Tested and approved by QA

        Show
        Rui Silva (Inactive) added a comment - Tested and approved by QA

          People

          • Assignee:
            Unassigned
            Reporter:
            Paulo Bras (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: