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

eZTemplate->appendDebugNodes generates a warning on specific case

    XMLWordPrintable

Details

    Description

      I've coded a custom datatype mydatatype, but I don't need any template for the class/datatype/view

      so I don't create the extension/myextension/design/standard/templates/class/datatype/view/mydatatype.tpl

      but then eZ complains with:

      Warning: eZTemplate:class_attribute_view_gui 	Aug 24 2011 15:55:22
      
      None of the templates design:class/datatype/view/mydatatype.tpl, design:class/datatype/view/.tpl could be found
      

      (First miscellaneous remark, eZ searchs class/datatype/view/.tpl which doesn't exist of course... but nevermind)

      Well I'm ok with this warning, we should have a template, even an empty one to say eZ "well I use a template, but this one does nothing"

      So I create an empty template, (with no newline in it), indeed I create it with the command:

      touch extension/myextension/design/standard/templates/class/datatype/view/mydatatype.tpl
      

      => But then, I get a warning:

      Warning: PHP: E_WARNING 	Aug 24 2011 16:01:44
      
      array_merge() [<a href='function.array-merge'>function.array-merge</a>]: Argument #2 is not an array in [...]/lib/eztemplate/classes/eztemplate.php on line 1748
      

      The warning comes from:

          function appendDebugNodes( &$root, &$resourceData )
          {
              $path = $resourceData['template-filename'];
              // Do not ouput debug on pagelayout templates to avoid trigering
              // browser quirks mode
              if ( isset( $root[1][0][2] ) && is_string( $root[1][0][2] ) && strpos( $root[1][0][2], '<!DOCTYPE' ) === 0 )
                  return;
              $uri = $resourceData['uri'];
              $preText = "\n<!-- START: including template: $path ($uri) -->\n";
              if ( eZTemplate::isXHTMLCodeIncluded() )
                  $preText .= "<p class=\"small\">$path</p><br/>\n";
              $postText = "\n<!-- STOP: including template: $path ($uri) -->\n";
              $root[1] = array_merge( array( eZTemplateNodeTool::createTextNode( $preText ) ), $root[1] );
              $root[1][] = eZTemplateNodeTool::createTextNode( $postText );
          }
      

      Indeed with a blank template $root[1] is empty, so not an array, hence the warning.
      Further more, in my debug, I can see the :

      <!-- STOP: including template: extension/myextension/design/standard/templates/class/datatype/view/mydatatype.tpl (design:class/datatype/view/mydatatype.tpl) -->
      

      but not the <!-- START: including.... -->

      A quick solution is to add some \n in my extension/myextension/design/standard/templates/class/datatype/view/mydatatype.tpl to avoid this warning

      => so maybe you should consider testing $root[1] ? like:

      $root[1] = array_merge( array( eZTemplateNodeTool::createTextNode( $preText ) ), $root[1]  ?$root[1] : array() );
      

      Attachments

        Activity

          People

            andre1 andre1
            enzo enzo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: