Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: maestrosite.ru on February 13, 2012, 11:21:33 AM

Title: HTML-layout error in GenericList.template.php
Post by: maestrosite.ru on February 13, 2012, 11:21:33 AM
Where the Error Occurred

    File: GenericList.template.php
    Line: 86-110,
    Any relevant errors in the SMF error log (if so please post them)?:

1. Start tag for tbody-element print in if-section.
lines: 86-110
Quote
   if (!($header_count < 2 && empty($cur_list['headers'][0]['label'])))
   {
      echo '
         <thead>
            <tr class="catbg">';
...
      echo '
            </tr>
         </thead>
         <tbody>';
   }

2. But end tag have unconditional print (echo without any conditionals)
lines: 139-142:
Quote
   echo '
         </tbody>
         </table>';

Total: if current list have not headers then result layout not valid - missing <tbody>.


Additionally for this function.
Don`t check existing of current list:
lines:17-19
Quote
   // Get a shortcut to the current list.
   $list_id = $list_id === null ? $context['default_list'] : $list_id;
   $cur_list = &$context[$list_id];

May be add something of this :
Quote
if( empty($context['default_list']) )
   retrun;
if( empty($context[$list_id]) )
   retrun;
Title: Re: HTML-layout error in GenericList.template.php
Post by: emanuele on February 15, 2012, 03:20:20 PM
Hi maestrosite.ru,

thank you for the report.

The first one is for sure a bug.
Title: Re: HTML-layout error in GenericList.template.php
Post by: emanuele on June 28, 2012, 05:34:18 AM
The second is an assumption in the code (i.e. the code assume the list exists)...maybe some kind of warning if it doesn't?
Title: Re: HTML-layout error in GenericList.template.php
Post by: maestrosite.ru on June 28, 2012, 07:41:56 AM
Sorry, i dont understabd your thought
Title: Re: HTML-layout error in GenericList.template.php
Post by: emanuele on June 28, 2012, 08:17:49 AM
Sorry, I was thinking to another issue and the sentence is not very clear.

I mean that the current code does an assumption: the list exists.
And I agree it's not correct, at least it's not in line with (most of) the other the code in SMF.
What I'm wondering is: is it better to just "return;" or maybe create a sort of error like: "the list doesn't exist"?
Title: Re: HTML-layout error in GenericList.template.php
Post by: maestrosite.ru on June 28, 2012, 08:38:16 AM
Of course, better is show error! I'm wrote code only for example.
(And I think best - throw Exception, but is not SMF-way)
Title: Re: HTML-layout error in GenericList.template.php
Post by: Arantor on January 17, 2014, 04:37:32 PM
The first was fixed in 2.1 some time ago, the second I've just changed in 2.1 to not throw an error (throwing an error of any kind from the template itself would be a bit awkward and inconsistent)