Bug #31347

Empty label in Frontend

Added by Xavier Perseguers almost 11 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Must have
Category:
-
Target version:
-
Start date:
2011-10-27
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.6
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Empty options (no label) when showing registration form of seminar.

After digging into the code, seminar sends prices to ameos_formidable to generate the select options in api/base/rdt_listbox/api/class.tx_rdtlistbox.php:

$sCaption = $this->oForm->_getLLLabel(
    $aItem["caption"]
);

The "problem" is that seminar is giving aemos_formidable the actual caption to be displayed instead of a localization key and the returned string is empty!

I bug fixed it with:

if (!$sCaption) $sCaption = $aItem['caption'];

However, is this a breaking change that we introduced in 4.6 by accident?

#1

Updated by Markus Klein almost 11 years ago

Yes and No.
Also div2007 has it's own function for dealing with getLL and since the structure of pibase->LOCAL_LANG has changed, all these lib functions are broken.

sr_feuser_register for example only displays "Array" instead of the labels. (Already contacted Franz concerning this bug in div2007)

#2

Updated by Xavier Perseguers almost 11 years ago

If I change the behavior of sL() within tslib_fe by removing the final return and adding this logic then, it fixes the bug:

if (!$this->LL_labels_cache[$this->lang][$input]) {
    $output = $input;
} else {
    $output = $this->LL_labels_cache[$this->lang][$input];
}
return $output;
#3

Updated by Oliver Klee almost 11 years ago

So, is this a bug in the way the seminars extension, a bug in the ameos_formidable extension or a Core bug?

#4

Updated by Markus Klein almost 11 years ago

Ok seems to be a different story here then.
(Didn't have a look at ameos_formidable, but in the div2007 case it's not the Core's fault)

#5

Updated by Xavier Perseguers almost 11 years ago

The sL() method in 4.5:

        /**
         * Split Label function for front-end applications.
         *
         * @param       string          Key string. Accepts the "LLL:" prefix.
         * @return      string          Label value, if any.
         */
        function sL($input)     {
                if (strcmp(substr($input,0,4),'LLL:'))  {
                        $t = explode('|',$input);
                        return $t[$this->langSplitIndex] ? $t[$this->langSplitIndex] : $t[0];
                } else {
                        if (!isset($this->LL_labels_cache[$this->lang][$input])) {      // If cached label
                                $restStr = trim(substr($input,4));
                                $extPrfx='';
                                if (!strcmp(substr($restStr,0,4),'EXT:'))       {
                                        $restStr = trim(substr($restStr,4));
                                        $extPrfx='EXT:';
                                }
                                $parts = explode(':',$restStr);
                                $parts[0] = $extPrfx.$parts[0];
                                if (!isset($this->LL_files_cache[$parts[0]]))   {       // Getting data if not cached
                                        $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
                                }
                                $this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1],$this->LL_files_cache[$parts[0]]);
                        }
                        return $this->LL_labels_cache[$this->lang][$input];
                }
        }

and in 4.6:

        /**
         * Split Label function for front-end applications.
         *
         * @param       string          Key string. Accepts the "LLL:" prefix.
         * @return      string          Label value, if any.
         */
        function sL($input)     {
                        // If cached label
                if (!isset($this->LL_labels_cache[$this->lang][$input])) {
                        $restStr = trim(substr($input,4));
                        $extPrfx='';
                        if (!strcmp(substr($restStr,0,4),'EXT:'))       {
                                $restStr = trim(substr($restStr,4));
                                $extPrfx='EXT:';
                        }
                        $parts = explode(':',$restStr);
                        $parts[0] = $extPrfx.$parts[0];
                                // Getting data if not cached
                        if (!isset($this->LL_files_cache[$parts[0]])) {
                                $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]);
                        }
                        $this->LL_labels_cache[$this->lang][$input] = $this->getLLL($parts[1],$this->LL_files_cache[$parts[0]]);
                }
                return $this->LL_labels_cache[$this->lang][$input];
        }

I'd say that this is an edge-case because in 4.5 the splitLabel feature allowed a non-existing key to be used (in fact a split label which in this case was not "split" at all) and it worked. In 4.6, split label support has been removed and as such the support for non-existing keys as well.

#6

Updated by Helmut Hummel almost 11 years ago

Xavier Perseguers wrote:

In 4.6, split label support has been removed and as such the support for non-existing keys as well.

So what happens if you call the method with a non existing label? Expected result would be that the label is returned, wouldn't it?

#7

Updated by Xavier Perseguers almost 11 years ago

  • Status changed from New to Accepted
  • Priority changed from Should have to Must have

OK, so in previous versions of TYPO3, calling $GLOBALS['TSFE']->sL() with a non label (text constant) returned the text itself ("split-label" with a single item).

Calling it with an invalid label reference (starting with "LLL:" but pointing nowhere) returns an empty string, just as we do now.

So in short, we should just return the input string itself whenever it does not start with "LLL:", this way we drop full support for split-label as announced but still make localization of non-references work as it was the case before.

This will match the corresponding method in class language ($GLOBALS['LANG']) and will help streamlining both APIs.

#8

Updated by Mr. Hudson almost 11 years ago

  • Status changed from Accepted to Under Review

Patch set 1 of change I2847e51fd479d9636ac815c820b2e63cf449d6a7 has been pushed to the review server.
It is available at http://review.typo3.org/6364

#9

Updated by Mr. Hudson almost 11 years ago

Patch set 2 of change I2847e51fd479d9636ac815c820b2e63cf449d6a7 has been pushed to the review server.
It is available at http://review.typo3.org/6364

#10

Updated by Mr. Hudson almost 11 years ago

Patch set 1 of change I98362a2701384f13fad80832eafc56ba494e8c34 has been pushed to the review server.
It is available at http://review.typo3.org/6368

#11

Updated by Xavier Perseguers almost 11 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#12

Updated by Benni Mack almost 4 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF