Typo3 – Easy upgrade of pibase extension to TYPO3 6.2 or 7.6

After upgrading a Typo3 4.5 Installation to Version 6.2 your old pibase extension may still running. Hmm .. at least mostly 🙂
You just need to remove some requice_once statements and modify the ext_table.php to use the \TYPO3\CMS\Core\Utility\ExtensionManagementUtility class. Most of the other stuff is still there.
Once when you try to upgrade to version 7.6 you are in need to modify a bit more. But don’t worry. After all it isn’t that complicated. And by the way … you don’t need to wait until you upgrade. These changes are running very well even in an 6.2 installation.
So here is a small list of needed action to upgrade from 4.5 via 6.2 to 7.6 🙂

  • Remove lines starting with require_once that includes TYPO3 core files
  • Remove any t3lib_div::loadTCA(“tt_content”)
  • Replace any t3lib_extMgm:: with \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::
  • Replace any t3lib_div:: with \TYPO3\CMS\Core\Utility\GeneralUtility::
  • Replace any tslib_pibase with \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
  • Replace any tslib_cObj with TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer

Or just use these commands (which do all but the first of the list): Of course do a backup before!

find . -type f -print0 | xargs -0 sed -i 's#t3lib_div::intInRange#\\TYPO3\\CMS\\Core\\Utility\\MathUtility::forceIntegerInRange#g'
find . -type f -print0 | xargs -0 sed -i 's#t3lib_div::loadTCA#//t3lib_div::loadTCA#g'
find . -type f -print0 | xargs -0 sed -i 's#t3lib_extMgm::#\\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility::#g'
find . -type f -print0 | xargs -0 sed -i 's#t3lib_div::#\\TYPO3\\CMS\\Core\\Utility\\GeneralUtility::#g'
find . -type f -print0 | xargs -0 sed -i 's#tslib_pibase#\\TYPO3\\CMS\\Frontend\\Plugin\\AbstractPlugin#g'
find . -type f -print0 | xargs -0 sed -i 's#tslib_cObj#TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer#g'

You have more old class names in use? Just check yourself which is the new name: https://docs.typo3.org/typo3cms/CoreApiReference/6.2/ApiOverview/Namespaces/Index.html

Old makeInstance

Instead of makeInstance you should use the objectManager:

old:
$TSFE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController', $TYPO3_CONF_VARS, 0, 0);

new:
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$TSFE = $objectManager->get('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $TYPO3_CONF_VARS, $id, 0);

Access to external Database

Instead of

$this->netDB = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_DB');
if ( !$result = $this->netDB->sql_pconnect( $this->dbHost, $this->dbUser, $this->dbPwd) ) die( "couldn't connect to database ".$this-dbDb );
if ( !$this->netDB->sql_select_db( $this->dbDb ) ) die( "couldn't select database ".$this-dbDb );

use this:

$this->netDB = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
$this->netDB->setDatabaseName( $this->dbDb );
$this->netDB->setDatabaseUsername( $this->dbUser );
$this->netDB->setDatabasePassword( $this->dbPwd );
$this->netDB->setDatabaseHost( $this->dbHost );
// $this->netDB->setDatabasePort( 3306 );

try {
$this->netDB->connectDB();
}
catch ( \Exception $ex )
{
die( $ex->getMessage() );
}

TCA

Furthermore check you tca.php (Version 7.6 or higher):

old:
'script' => 'browse_links.php?mode=wizard&act=file'

new:
'module' => array(
'name' => 'wizard_element_browser',
'urlParameters' => array(
'mode' => 'wizard',
'act' => 'file'
)
)

And you need to add a renderType for every 'type' => 'select'. Check your options.

Some useful links