Bug #45513
closedpi_getLL does not allow clearing labels via Typoscript any more
100%
Description
Since TYPO3 4.7.4 (in 4.5 the issue does not exist) it is not possible anymore to clear a language label.
Example:
pi_list_browseresults_page is a label used in pibase->pi_list_browseresults to prepend e.g. "Page" to the links to pages, so you get "Page 1 - Page 2 - Page 3 - ..." as links. The fallback value in browseresults is "Page":
$pageText = trim($this->pi_getLL('pi_list_browseresults_page','Page',$hscText).' '.($a+1));
Before 4.7.5 it was possible to add Typoscript in the template like this:
plugin.tx_myplugin_using_pagebrowse { _LOCAL_LANG.de { pi_list_browseresults_page = } }
resulting in a cleared pi_list_browseresults_page that produces the links "1 - 2 - 3 - ...".
This is due to the !empty-check in pi_getLL - it does not allow an empty string and directly jumps to the else case.
public function pi_getLL($key, $alternativeLabel = '', $hsc = FALSE) { $word = NULL; if (!empty($this->LOCAL_LANG[$this->LLkey][$key][0]['target'])) {
Using a check like this resolves the problem:
public function pi_getLL($key, $alternativeLabel = '', $hsc = FALSE) { $word = NULL; if (!empty($this->LOCAL_LANG[$this->LLkey][$key][0])) {
No check for the actual value of the label but check, if there is a existing definition with source/target instead.
Updated by Markus Klein about 11 years ago
!empty($this->LOCAL_LANG[$this->LLkey][$key][0])
Using empty on an array is not the nicest piece of code one can imagine...
Updated by Patrick Broens about 11 years ago
- Category set to Localization
- Complexity set to easy
Updated by Stephan Großberndt about 11 years ago
Markus Klein wrote:
[...]
Using empty on an array is not the nicest piece of code one can imagine...
Why and what would you suggest?
Updated by Markus Klein about 11 years ago
Sorry, I thought that this was clear, my mistake.
I'd prefer to have a simple is_array()
or even isset()
check on [$key][0]
instead of empty()
.
I'm not sure if [0] is always present. If so, then is_array()
is sufficient, otherwise isset()
is mandatory to avoid PHP warnings.
Updated by Georg Ringer almost 11 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100