/** * @param Tx_Smoothmigration_Domain_Model_Issue $issue * * @return string */ public function getSolution(Tx_Smoothmigration_Domain_Model_Issue $issue) { if (is_string($issue->getAdditionalInformation())) { $additionalInformation = unserialize($issue->getAdditionalInformation()); } else { $additionalInformation = $issue->getAdditionalInformation(); } switch ($additionalInformation['type']) { case 'configuration': $result = $this->ll('result.typo3-database-database-utf8.databaseServerSetting', array($additionalInformation['setting'], $additionalInformation['actualValue'], $additionalInformation['preferredValue'])); break; case 'databaseCollation': $result = $this->ll('result.typo3-database-database-utf8.databaseCollation', array($additionalInformation['characterSet'], $additionalInformation['defaultCollation'], 'utf8', 'utf8_general_ci')); break; case 'tableCollation': $result = $this->ll('result.typo3-database-database-utf8.databaseTableCollation', array($additionalInformation['tableName'], $additionalInformation['tableCollation'], 'utf8_general_ci')); break; case 'columnCollation': $result = $this->ll('result.typo3-database-database-utf8.databaseColumnCollation', array($additionalInformation['tableName'], $additionalInformation['columnName'], $additionalInformation['characterSetName'], $additionalInformation['collationName'])); break; default: $result = ''; } return $result; }
/** * Handle issue * * @param Tx_Smoothmigration_Domain_Model_Issue $issue * @return void */ protected function handleIssue(Tx_Smoothmigration_Domain_Model_Issue $issue) { if (is_string($issue->getLocationInfo())) { $locationInfo = unserialize($issue->getLocationInfo()); } else { $locationInfo = $issue->getLocationInfo(); } if (is_string($issue->getAdditionalInformation())) { $additionalInformation = unserialize($issue->getAdditionalInformation()); } else { $additionalInformation = $issue->getAdditionalInformation(); } if ($additionalInformation['isReplaceable'] == 1) { // No brainer, can be replaced all the time $this->performReplacement($issue, $locationInfo, $additionalInformation); } elseif ($additionalInformation['isReplaceable'] == 2) { // Not a no brainer, but might be replaced if ($this->experimental) { $this->performReplacement($issue, $locationInfo, $additionalInformation); } elseif (!$this->encounteredExperimentalIssues) { $this->messageService->message($locationInfo->getFilePath() . ' line: ' . $locationInfo->getLineNumber() . LF . 'Method [' . trim($locationInfo->getMatchedString()) . '] is not easily replaceable.' . LF . $additionalInformation['deprecationMessage']); $this->messageService->warningMessage('But you can try fixing. Run again with parameter --experimental=yes'); $this->messageService->warningMessage($this->ll('migration.manualInterventionNeeded'), TRUE); $this->encounteredExperimentalIssues = TRUE; } } else { $this->messageService->message($locationInfo->getFilePath() . ' line: ' . $locationInfo->getLineNumber() . LF . 'Method [' . trim($locationInfo->getMatchedString()) . '] is not easily replaceable.' . LF . $additionalInformation['deprecationMessage']); if ($additionalInformation['replacementMessage']) { $this->messageService->message($additionalInformation['replacementMessage']); } $this->messageService->warningMessage($this->ll('migration.manualInterventionNeeded'), TRUE); $this->messageService->message(); } }
/** * @param Tx_Smoothmigration_Domain_Model_Issue $issue * * @return string */ public function getRawTextForCopyPaste(Tx_Smoothmigration_Domain_Model_Issue $issue) { $information = $issue->getAdditionalInformation(); $originalClass = $information['ORIGINAL_CLASS']; $newClass = $information['IMPLEMENTATION_CLASS']; return $this->ll('result.typo3-core-code-xclasses.raw', array($originalClass, $newClass)); }
/** * Handle issue * * @param Tx_Smoothmigration_Domain_Model_Issue $issue * * @return void */ protected function handleIssue(Tx_Smoothmigration_Domain_Model_Issue $issue) { if (is_string($issue->getLocationInfo())) { $locationInfo = unserialize($issue->getLocationInfo()); } else { $locationInfo = $issue->getLocationInfo(); } $physicalLocation = $locationInfo->getPhysicalLocation(); // first retrieve the old ext_localconf.php that contained the xclass $physicalPath = str_replace('EXT:', 'ext/', $physicalLocation->getFilePath()); if (file_exists(PATH_site . 'typo3conf/' . $physicalPath)) { $physicalPath = PATH_site . 'typo3conf/' . $physicalPath; } elseif (file_exists(PATH_site . 'typo3/sys' . $physicalPath)) { $physicalPath = PATH_site . 'typo3/sys' . $physicalPath; } elseif (file_exists(PATH_site . $physicalPath)) { $physicalPath = PATH_site . $physicalPath; } else { return; } $additionalInfo = $issue->getAdditionalInformation(); $extPath = substr(0, -17, $physicalPath); if (file_exists(substr(0, -4, $physicalPath) . '.obsolete.php')) { // if it has already been processed, because it contains more than just one xclass, rebuild the new ext_localconf.php and ext_autoload.php by adding the current classes etc $xClasses = (require $extPath . 'ext_autoload.php'); $extLocalconfSource = substr(0, -2, file_get_contents($physicalPath)); $xClasses[$additionalInfo['IMPLEMENTATION_CLASS']] = $additionalInfo['IMPLEMENTATION_CLASS_FILENAME']; $extLocalconfSource .= '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'Objects\'][\'' . $additionalInfo['ORIGINAL_CLASS'] . '\'] = array(\'className\' => \'' . $additionalInfo['IMPLEMENTATION_CLASS'] . '\');' . "\n?>"; file_put_contents($physicalPath, $extLocalconfSource); unset($extLocalconfSource); $newAutoloadSource = '<?php return array(' . "\n"; foreach ($xClasses as $xclass => $path) { $newAutoloadSource .= '\'' . $xclass . '\' => \'' . $path . '\',' . "\n"; } file_put_contents($extPath . 'ext_autoload.php', $newAutoloadSource . '); ?>'); } else { // else rename the ext_localconf.php and create a new one with the new style and also create the ext_autoload.php rename($physicalPath, substr(0, -4, $physicalPath) . '.obsolete.php'); $extLocalconfSource = "<?php\n" . '$GLOBALS[\'TYPO3_CONF_VARS\'][\'SYS\'][\'Objects\'][\'' . $additionalInfo['ORIGINAL_CLASS'] . '\'] = array(\'className\' => \'' . $additionalInfo['IMPLEMENTATION_CLASS'] . '\');' . "\n?>"; file_put_contents($physicalPath, $extLocalconfSource); $xClassCode = "<php\n" . 'return array(\'' . $additionalInfo['IMPLEMENTATION_CLASS'] . '\'=> \'' . $additionalInfo['IMPLEMENTATION_CLASS_FILENAME'] . '\',);' . "\n?>"; file_put_contents($extPath . 'ext_autoload.php', $xClassCode); } }
/** * Handle issue * * @param Tx_Smoothmigration_Domain_Model_Issue $issue * @return void */ protected function handleIssue(Tx_Smoothmigration_Domain_Model_Issue $issue) { if (is_string($issue->getLocationInfo())) { $locationInfo = unserialize($issue->getLocationInfo()); } else { $locationInfo = $issue->getLocationInfo(); } if (is_string($issue->getAdditionalInformation())) { $additionalInformation = unserialize($issue->getAdditionalInformation()); } else { $additionalInformation = $issue->getAdditionalInformation(); } $allowedCollations = array('utf8_general_ci', 'utf8_unicode_ci', 'utf8_general_cs', 'utf8_unicode_cs', 'utf8_bin'); switch ($additionalInformation['type']) { case 'configuration': $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseServerSetting', array($additionalInformation['setting'], $additionalInformation['actualValue'], $additionalInformation['preferredValue']))); $this->messageService->warningMessage($this->ll('migration.manualInterventionNeeded'), TRUE); $this->messageService->message(); break; case 'databaseCollation': $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseCollation', array($additionalInformation['characterSet'], $additionalInformation['defaultCollation']))); $collation = 'utf8_general_ci'; if (in_array($additionalInformation['defaultCollation'], $allowedCollations)) { $collation = $additionalInformation['defaultCollation']; } if ($issue->getMigrationStatus() != 0) { $this->messageService->successMessage($this->ll('migration.alreadyMigrated'), TRUE); return; } $query = 'ALTER DATABASE CHARACTER SET utf8 COLLATE ' . $collation . ';'; $this->messageService->message($this->ll('migration.executingQuery', array($query))); $GLOBALS['TYPO3_DB']->sql_query($query); if ($sqlError = $GLOBALS['TYPO3_DB']->sql_error()) { $this->messageService->errorMessage($sqlError . LF, TRUE); } $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS); $this->messageService->successMessage($this->ll('migrationsstatus.1') . LF, TRUE); break; case 'tableCollation': $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseTableCollation', array($additionalInformation['tableName'], $additionalInformation['tableCollation'], 'utf8_general_ci'))); if ($issue->getMigrationStatus() != 0) { $this->messageService->successMessage($this->ll('migration.alreadyMigrated'), TRUE); return; } $query = 'ALTER TABLE `' . $additionalInformation['tableName'] . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'; $this->messageService->message($this->ll('migration.executingQuery', array($query))); $GLOBALS['TYPO3_DB']->sql_query($query); if ($sqlError = $GLOBALS['TYPO3_DB']->sql_error()) { $this->messageService->errorMessage($sqlError . LF, TRUE); } else { $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS); $this->messageService->successMessage($this->ll('migrationsstatus.1') . LF, TRUE); } break; case 'columnCollation': $this->messageService->message($this->ll('result.typo3-database-database-utf8.databaseColumnCollation', array($additionalInformation['tableName'], $additionalInformation['columnName'], $additionalInformation['characterSetName'], $additionalInformation['collationName']))); if ($issue->getMigrationStatus() != 0) { $this->messageService->successMessage($this->ll('migration.alreadyMigrated'), TRUE); return; } $query = 'ALTER TABLE `' . $additionalInformation['tableName'] . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'; $this->messageService->message($this->ll('migration.executingQuery', array($query))); $GLOBALS['TYPO3_DB']->sql_query($query); if ($sqlError = $GLOBALS['TYPO3_DB']->sql_error()) { $this->messageService->errorMessage($sqlError . LF, TRUE); } else { $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS); $this->messageService->successMessage($this->ll('migrationsstatus.1') . LF, TRUE); } break; default: } }