Project

General

Profile

Actions

Bug #41632

closed

t3lib_l10n_parser_Llxml::getParsedData gives an error Call to undefined method getCharset

Added by Simon Child over 11 years ago. Updated over 10 years ago.

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

0%

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

Description

deprecation log for 4.7.4 says to use t3lib_l10n_parser_Llxml::getParsedData instead of t3lib_div::readLLXMLfile

But using t3lib_l10n_parser_Llxml::getParsedData gives an error Call to undefined method getCharset

Indeed t3lib_l10n_parser_Llxml::getParsedData calls getCharset

$this->charset = $this->getCharset($languageKey, $charset);

But t3lib_l10n_parser_Llxml does not contain any method getCharset

t3lib_l10n_parser_abstractxml.php does contain a protected function getCharset - does that need copying to t3lib_l10n_parser_Llxml??

Actions #1

Updated by Xavier Perseguers over 11 years ago

  • Status changed from New to Needs Feedback

Class t3lib_l10n_parser_Llxml extends t3lib_l10n_parser_AbstractXml so no need to copy the method which gets inheritated.

Please post the stack trace of your error and possibly a code snippet generating this error.

Actions #2

Updated by Thomas Dudzak over 11 years ago

Same problem in td_calendar-extension. Extensions wizicon file calls in a version-switch:

if ($version >= 4007000) {
    $LOCAL_LANG =  t3lib_l10n_parser_Llxml::getParsedData($llFile, $GLOBALS['LANG']->lang);
} else {
    $LOCAL_LANG =  t3lib_div::readLLXMLfile($llFile, $GLOBALS['LANG']->lang);
}

and gets this error:

Fatal error: Call to undefined method tx_tdcalendar_pi1_wizicon::getCharset() in /home.../t3lib/l10n/parser/class.t3lib_l10n_parser_llxml.php on line 55

So, it seems to me that issue: t3lib_l10n_parser_Llxml::getParsedData-function is called directly without including the parser-Class, but tries to call getCharset as part of "its" class. This error will occur more frequently because of deprecation of t3lib_div::readLLXMLfile in TYPO3 6.0... Would be kind to proof, if getCharset-code is wheather to include into t3lib_l10n_parser_Llxml::getParsedData() or if it is possible to call it without expand the wizicon-class.

Actions #3

Updated by Stephen Bungert over 11 years ago

I'm having this problem too when trying to make an extension work in 6.0

Actions #4

Updated by Stephen Bungert over 11 years ago

class.tx_sbportfolio_pi1_wizicon.php

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2009-2012 Stephen Bungert <stephenbungert@yahoo.de>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
 * [CLASS/FUNCTION INDEX of SCRIPT]
 *
 *
 *
 *   48: class tx_sbportfolio_pi1_wizicon
 *   56:     function proc($wizardItems)
 *   76:     function includeLocalLang()
 *
 * TOTAL FUNCTIONS: 2
 * (This index is automatically created/updated by the extension "extdeveval")
 *
 */

/**
 * Class that adds the wizard icon.
 *
 * @author    Stephen Bungert <stephenbungert@yahoo.de>
 * @package    TYPO3
 * @subpackage    tx_sbportfolio
 */
class tx_sbportfolio_pi1_wizicon {

                    /**
 * Processing the wizard items array
 *
 * @param    array        $wizardItems: The wizard items
 * @return    Modified        array with wizard items
 */
                    function proc($wizardItems)    {
                        global $LANG;

                        $LL = $this->includeLocalLang();

                        $wizardItems['plugins_tx_sbportfolio_pi1'] = array(
                            'icon'=>t3lib_extMgm::extRelPath('sb_portfolio').'pi1/ce_wiz.gif',
                            'title'=>$LANG->getLLL('pi1_title',$LL),
                            'description'=>$LANG->getLLL('pi1_plus_wiz_description',$LL),
                            'params'=>'&defVals[tt_content][CType]=list&defVals[tt_content][list_type]=sb_portfolio_pi1'
                        );

                        return $wizardItems;
                    }

                    /**
 * Reads the [extDir]/locallang.xml and returns the $LOCAL_LANG array found in that file.
 *
 * @return    The        array with language labels
 */
                    function includeLocalLang()    {
                        $t3Version = class_exists('t3lib_utility_VersionNumber') ? t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) : t3lib_div::int_from_ver(TYPO3_version);

                        $llFile        = t3lib_extMgm::extPath('sb_portfolio').'locallang.xml';
                        $LOCAL_LANG    = '';

                        if ($t3Version >= 4007000) {
                            $LOCAL_LANG = t3lib_l10n_parser_Llxml::getParsedData($llFile, $GLOBALS['LANG']->lang);

                        } else if ($t3Version >= 4006000) {
                            $LOCAL_LANG = t3lib_div::readLLXMLfile($llFile, $GLOBALS['LANG']->lang);

                        } else {
                            $LOCAL_LANG = t3lib_div::readLLfile($llFile, $GLOBALS['LANG']->lang);
                        }

                        return $LOCAL_LANG;
                    }
                }

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sb_portfolio/pi1/class.tx_sbportfolio_pi1_wizicon.php'])    {
    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sb_portfolio/pi1/class.tx_sbportfolio_pi1_wizicon.php']);
}

?>
Actions #5

Updated by Johannes C. Schulz over 11 years ago

Hello

I also run into this problem. Tried to patch all extensions from my project on 6.0.0 (tt_address, tt_news, formhandler, ...) but now I the "called undefined method getCharset()"-error appears.

Waiting for a fix...

Actions #6

Updated by Michael B. over 11 years ago

Any Quick-Fix for this error? Currently this error disables adding new records on my page... Hope this gets fixed as so as possible. Did not find any solution by my own for this error.

Actions #7

Updated by Johannes C. Schulz over 11 years ago

Michael B. wrote:

Did not find any solution by my own for this error.

No sorry, just waiting for a core-fix...

Actions #8

Updated by Thomas Dudzak over 11 years ago

According to my code i posted in #2 i have solved the problem IN THE EXTENSION on that way:

/**
    * Reads the [extDir]/locallang.xml and returns the $LOCAL_LANG array found in that file.
    *
    * @return    The        array with language labels
    */
    function includeLocalLang()    {
        $llFile = t3lib_extMgm::extPath('td_calendar').'locallang.xml';

        $version =     class_exists('t3lib_utility_VersionNumber')
                    ? t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version)
                    : t3lib_div::int_from_ver(TYPO3_version);
        if ($version >= 4007000) {
                $object = t3lib_div::makeInstance('t3lib_l10n_parser_Llxml');
                $LOCAL_LANG =  $object->getParsedData($llFile, $GLOBALS['LANG']->lang);
        } else {
            $LOCAL_LANG =  t3lib_div::readLLXMLfile($llFile, $GLOBALS['LANG']->lang);
        }

        return $LOCAL_LANG;
    }

i start a new instance of t3lib_l10n_parser_Llxml before using getParsedDate(). it's not the very fine way, i think, this is a core issue, not an issue for extension developers. but it works and should help until the problem is solved. please make sure that you fit the snippet to your needs, it's just a copy&paste from my extension.

Actions #9

Updated by Ingo Renner over 11 years ago

The issue is, that people try to use the method through a static call, while they need to use an instance...

There's not really a way to solve this other than providing a hint in documentation I guess.

Actions #10

Updated by Thomas Dudzak about 11 years ago

Well, I think, this is a solution, Ingo. Just saw that getCharset is a protected function. It's a deep cut in habits of extension developers but should be okay... Is it possible to give kickstarter an update in that way (I assume, extension builder had one) to avoid irritations?

Actions #11

Updated by Andrey Aksenov almost 11 years ago

Same error in the latest version of TYPO3 6.1.1. I have to fix a lot of code in extensions! Is there another solution?

Actions #12

Updated by Alexander Opitz almost 11 years ago

As Ingo already wrote, the problem is that you call a non-static function in the static way.

But TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile($llFile, $GLOBALS['LANG']->lang) should do what you need and can be called staticaly.

Actions #13

Updated by Alexander Opitz almost 11 years ago

Btw.: In 4.6/4.7 you also have t3lib_div::readLLfile($llFile, $GLOBALS['LANG']->lang) as static function.

Actions #14

Updated by Alexander Opitz over 10 years ago

  • Status changed from Needs Feedback to Closed
  • Is Regression set to No

No feedback for over 90 days.

If you think, that this is the wrong decision, then please write to the mailing list typo3.teams.bugs with issue number and an explanation.

Actions

Also available in: Atom PDF