TYPO3 4.3 deprecated methods

Upgrading to TYPO3 4.3 causes typo3 to write every call to a deprecated method to a file called deprecation_XXXXXXXXXX.log in the typo3conf folder. This kind of sucks and the file gets quite long. I found that main cause for this annoying behaviour are two function calls from extensions: »makeInstanceClassName« and »GPvar«. Either you upgrade all your extensions hoping the upgrade fixes the Problem or just perform the following in your ext folder. Make sure you backup all your extensions before you just copy paste!

grep -rl makeInstanceClassName * | grep ‚\.php$‘ | grep -v ‚/\.svn/‘ | xargs sed -i -e „s/makeInstanceClassName/makeInstance/g“
grep -rl GPvar * | grep ‚\.php$‘ | grep -v ‚/\.svn/‘ | xargs sed -i -e „s/GPvar/_GP/g“

If you want to make sure not to break anything just dry run the following two lines and read the output before you perform the two lines mentioned above:

grep -r makeInstanceClassName * | grep ‚\.php$‘ | grep -v ‚/\.svn/‘
grep -r GPvar * | grep ‚\.php$‘ | grep -v ‚/\.svn/‘

3 Gedanken zu „TYPO3 4.3 deprecated methods“

  1. Hi,

    usually you’d like to keep compatibility with older TYPO3 versions – therefore replacing the makeInstanceClassName directly with makeInstance might not be the best choice.

    I’d suggest to transform such blocks:

    $className = t3lib_div::makeInstanceClassName(‘tx_myext_class’);
    $object = new $className($arg1, $arg2);
    

    into something like this:

    if (version_compare(TYPO3_version,'4.3','>')) {
      $object = t3lib_div::makeInstance('tx_myext_class', $arg1, $arg2);
    } else {
      $className = t3lib_div::makeInstanceClassName('tx_myext_class');
      $object = new $className($arg1, $arg2);
    }
    

    This way you make sure that the deprecation.log doesn’t fill up and you can still use this extension for older TYPO3 versions.

    Cheers,
    Tolleiv

  2. In most cases the workaround of Tolleiv is not necessary t3 moves forward not backward and I experienced 99,9% failsafeness doing so. Mark my words Make a backup!. In case you face difficulties you should seriously consider to get rid of the extension you are using (to say it might have other lacks also including security).

  3. use insted of

    if (version_compare(TYPO3_version,’4.3′,’>‘)) {

    better
    if (version_compare(TYPO3_version,’4.3′,’>=‘)) {

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.