Apen / additional_reports

Useful information in the reports module : xclass, ajax, cliKeys, eID, general status of the system (encoding, DB, php vars...), hooks, compare local and TER extension (diff), used content type, used plugins, ExtDirect... It can really help you during migration or new existing project (to have a global reports of the system).
Other
12 stars 11 forks source link

Comparison of extension (local <-> TER) doesn't work if TYPO3 is installed in a subdirectory #7

Closed tobiasschaeferptb closed 6 years ago

tobiasschaeferptb commented 6 years ago

Hello,

if TYPO3 is installed in a subdirectory the url for the comparison is wrong because the subdirectory occurs in the url twice. If you click on the compare button it leeds to an 404 error. I fixed this by changing the function getExtensionInformations in Classes/mail.php a little bit: public static function getExtensionInformations($itemValue) { $extKey = $itemValue['extkey']; $listExtensionsTerItem = array(); $listExtensionsTerItem['icon'] = $itemValue['icon']; $listExtensionsTerItem['extension'] = $extKey; $listExtensionsTerItem['version'] = $itemValue['EM_CONF']['version']; $listExtensionsTerItem['versioncheck'] = \Sng\AdditionalReports\Utility::versionCompare($itemValue['EM_CONF']['constraints']['depends']['typo3']);

    // version compare
    $compareUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');

    $uriBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
    $routeIdentifier = 'additional_reports_compareFiles';
    $uri = (string)$uriBuilder->buildUriFromRoute($routeIdentifier, array());

    // Bugfix for wrong CompareUrl in case of TYPO3 is installed in a subdirectory
    if (strpos($uri, 'typo3') > 0) {
      $uri = substr($uri, strpos($uri, 'typo3'));
    }
    $compareUrl .= $uri;
    $compareUrl .= '&extKey=' . $extKey . '&mode=compareExtension&extVersion=' . $itemValue['EM_CONF']['version'];

Cheers, Tobias

tobiasschaeferptb commented 6 years ago

I just noticed that the diffs aren't shown in TYPO3 8.7.4 with additional_reports 3.1.0 anymore since the class TYPO3\CMS\Core\Utility\DiffUtility sets the variable $stripTags by default to true. To fix this I added $diff->stripTags = false; in additional_reports/Classes/Eid/class.tx_compareFiles_eID.php: function t3Diff($file1, $file2) { $diff = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Utility\DiffUtility'); if (version_compare(TYPO3_version, '7.6.0', '>=')) { // BugFix for not showing the diff $diff->stripTags = false; $sourcesDiff = $diff->makeDiffDisplay($file1, $file2); } else { $diff->diffOptions = '-bu'; $sourcesDiff = $diff->getDiff($file1, $file2); } printT3Diff($sourcesDiff); }

tobiasschaeferptb commented 6 years ago

Since the name of the subdirectory could start with typo3 I guess the code should be: if (strpos($uri, 'typo3/index.php') > 0) { $uri = substr($uri, strpos($uri, 'typo3/index.php')); }

Apen commented 6 years ago

Thanks for you feedback, look a the 3.1.1 version to test the fix.

tobiasschaeferptb commented 6 years ago

Thank you for the fix. The comparison feature works now.

tobiasschaeferptb commented 6 years ago

In Main.php in line 233 it should be: $uri = substr($uri, strpos($uri, 'typo3/index.php')); instead of: $uri = substr($uri, strpos($uri, 'typo3'));

Apen commented 6 years ago

Oops fixed in git version :-) I will wait a little bit to push another typo3 ter version.