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

Compiled ezini operator generates an error on missing variable even when not executed

    XMLWordPrintable

Details

    Description

      WAS: "ezini_hasvariable will always generate an error in log if the variable does not exist"

      The ezini operator will always make an entry in error.log if the variable does not exist - even when the operator is not executed. This is due to the way the template compiler works. It compiles all statements, even those that will not be executed.

      Assuming you use ezini_hasvariable() in a template to check for an ini variable, and then if it exists, use ezini() to read it. If the variable does not exist, the template compiler will always make an entry in error.log for ezini(), even though ezini() is never executed. This is because the error is generated on compile time, not on run time.

      Steps to Reproduce

      1. Set ezpublish.yml to execute a siteaccess with legacy_mode
      2. Edit your pagelayout.tpl and add the following code
        <!-- Hasvariable Test: START -->
        {if ezini_hasvariable( 'Links', 'Google', 'my_links.ini' )}
        	<a href="{ezini( 'Links', 'Google', 'my_links.ini' )}">I'm going to Google</a>
        {else}
        	<h3>I'm not going to Google</h3>
        {/if}
        <!-- Hasvariable Test: END 
        
      3. Don't create any my_links.ini file or create one in override with a mispelled name in the group or the variable
      4. Load the frontend and check var/log/error.log

        eZTemplate:ezini:
        No such variable 'Google' in group 'Links' for my_links.ini

      Attachments

        Activity

          People

            Unassigned Unassigned
            eduardo.fernandes-obsolete@ez.no Eduardo Fernandes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h