コード例 #1
0
 /**
  * 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();
     }
 }
コード例 #2
0
 /**
  * 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();
     }
     $this->performReplacement($issue, $locationInfo);
 }
コード例 #3
0
 /**
  * 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();
     }
     $this->messageService->message($locationInfo->getFilePath() . ':' . $locationInfo->getLineNumber() . ' [' . trim($locationInfo->getMatchedString()) . '] => ');
     if ($issue->getMigrationStatus() != 0) {
         $this->messageService->successMessage('already migrated', TRUE);
         return;
     }
     $newFileContent = '';
     if (!file_exists($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_FOUND);
         $this->messageService->errorMessage('Error, file not found', TRUE);
         return;
     }
     if (!is_writable($locationInfo->getFilePath())) {
         $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_WRITABLE);
         $this->messageService->errorMessage('Error, file not writable', TRUE);
         return;
     }
     $fileObject = new SplFileObject($locationInfo->getFilePath());
     // If more than one line needs to be removed from the same file, only the
     // first would succeed as the line numbering will change after removing
     // the first line. Therefore we need to keep track of the number of lines
     // removed per file. We use this offset to read the file.
     $lineOffset = $this->locationCounters[$locationInfo->getFilePath()];
     foreach ($fileObject as $lineNumber => $lineContent) {
         if ($lineNumber + 1 + $lineOffset != $locationInfo->getLineNumber()) {
             $newFileContent .= $lineContent;
         } else {
             $newLineContent = str_replace($locationInfo->getMatchedString(), LF, $lineContent);
             if ($newLineContent == $lineContent) {
                 $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::ERROR_FILE_NOT_CHANGED);
                 $this->messageService->errorMessage($this->ll('migrationsstatus.4'), TRUE);
                 return;
             }
             $newFileContent .= $newLineContent;
         }
     }
     file_put_contents($locationInfo->getFilePath(), $newFileContent);
     $issue->setMigrationStatus(Tx_Smoothmigration_Domain_Interface_Migration::SUCCESS);
     $this->messageService->successMessage('Succes', TRUE);
     if (!isset($this->locationCounters[$locationInfo->getFilePath()])) {
         $this->locationCounters[$locationInfo->getFilePath()] = 1;
     } else {
         $this->locationCounters[$locationInfo->getFilePath()]++;
     }
 }
コード例 #4
0
 /**
  * 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);
     }
 }
コード例 #5
0
 /**
  * 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:
     }
 }