Bug #39287

get_html_translation_table expects at most 2 parameters, 3 given

Added by Stephan Großberndt almost 9 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
Start date:
2012-07-26
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.7
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

When converting the encoding of a string an error message is added to the log:

Core: Error handler (FE): PHP Warning: get_html_translation_table() expects at most 2 parameters, 3 given in /xxxxxx/typo3/typo3_src-4.7.2/t3lib/class.t3lib_cs.php line 819

This happens because the encoding 'UTF-8' is given as third parameter, but this parameter has been added with PHP 5.3.4 [http://php.net/manual/en/function.get-html-translation-table.php#refsect1-function.get-html-translation-table-changelog].

The TYPO3 page [https://typo3.org/download/] states 5.3.x as required PHP version.

Since for Debian Squeeze only 5.3.3 is available, please add a workaround for 5.3.x versions older than 5.3.4.


Related issues

Related to TYPO3 Core - Task #34094: Change fallbacks to iso-8859-1 to utf-8ClosedSteffen Ritter2012-02-202012-02-20

Actions
#1

Updated by Stephan Großberndt almost 9 years ago

Workaround:

The lines

    function entities_to_utf8($str, $alsoStdHtmlEnt = FALSE) {
        if ($alsoStdHtmlEnt) {
            $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'UTF-8'));
        }


have to be replaced with
    function entities_to_utf8($str, $alsoStdHtmlEnt = FALSE) {
        if ($alsoStdHtmlEnt) {
            if (version_compare(PHP_VERSION, '5.3.4') >= 0) {
                $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES, ENT_COMPAT, 'UTF-8'));
            } else {
                $trans_tbl = array_flip(get_html_translation_table(HTML_ENTITIES, ENT_COMPAT));
                if (!empty($trans_tbl)) {
                    foreach ($trans_tbl as $key => $entry) {
                        $trans_tbl[$key] = utf8_encode($entry);
                    } 
                }
            }
        }

#2

Updated by Gerrit Code Review almost 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13504

#3

Updated by Gerrit Code Review almost 9 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13504

#4

Updated by Gerrit Code Review almost 9 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13504

#5

Updated by Gerrit Code Review almost 9 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13504

#6

Updated by Gerrit Code Review over 8 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13504

#7

Updated by Ernesto Baschny over 8 years ago

The effect of this bug are warnings like these in the log (since TYPO3 4.7):

Core: Error handler (FE): PHP Warning: array_flip() expects parameter 1 to be array, null given in /.../typo3_src/t3lib/class.t3lib_cs.php line 819

Core: Error handler (FE): PHP Warning: get_html_translation_table() expects at most 2 parameters, 3 given in /.../typo3_src/t3lib/class.t3lib_cs.php line 819

This happens for example when Indexed Search is indexing a page (in the frontend).

Fix solves it (at least in my test 4.7 environment). Will review it...

#8

Updated by Gerrit Code Review over 8 years ago

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at http://review.typo3.org/16790

#9

Updated by Ernesto Baschny over 8 years ago

I reviewed positively the master patch. I just didn't merge it yet because of the 6.0.0 release merge freeze, so I will ask Helmut if it's ok to do it anyway.

I already prepared a 4.7 backported patch (no cherry-picking possible because of different class names) and pushed it to gerrit. Since the code at this place didn't change between the versions (except the class name), I would merge it as "already reviewed and verified in upper version". No side-effects expected.

#10

Updated by Gerrit Code Review over 8 years ago

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at http://review.typo3.org/16949

#11

Updated by Michael Stucki over 8 years ago

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

Updated by Oliver Hader about 7 years ago

  • Is Regression set to No

Note: This change has been removed again in TYPO3 CMS 6.2 with bb49c3363910ee9b15b4f29f37b0f5bf83d6a041
I've added a work-around to this abandoned change set in case one is still running PHP 5.3.3: https://review.typo3.org/#/c/29593/

#13

Updated by Riccardo De Contardi over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF