[TASK] Replace PATH_site with Environment API in various exts 35/57235/2
authorBenni Mack <benni@typo3.org>
Fri, 15 Jun 2018 15:06:28 +0000 (17:06 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 15 Jun 2018 15:50:19 +0000 (17:50 +0200)
Resolves: #85278
Releases: master
Change-Id: Ibfcad90bad0486f7571ea60edd6aba33cab0c32c
Reviewed-on: https://review.typo3.org/57235
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/lowlevel/Classes/Command/LostFilesCommand.php
typo3/sysext/lowlevel/Classes/Command/MissingFilesCommand.php
typo3/sysext/lowlevel/Classes/Command/RteImagesCommand.php
typo3/sysext/lowlevel/Resources/Private/Language/locallang.xlf
typo3/sysext/recycler/Classes/Task/CleanerTask.php
typo3/sysext/rsaauth/Classes/BackendWarnings.php

index 2eb10da..efb3b03 100644 (file)
@@ -21,6 +21,7 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Style\SymfonyStyle;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -169,7 +170,7 @@ If you want to get more detailed information, use the --verbose option.')
      *
      * @param array $excludedPaths list of paths to be excluded, can be uploads/pics/
      * @param string $customPaths list of paths to be checked instead of uploads/
-     * @return array an array of files (relative to PATH_site) that are not connected
+     * @return array an array of files (relative to Environment::getPublicPath()) that are not connected
      */
     protected function findLostFiles($excludedPaths = [], $customPaths = ''): array
     {
@@ -178,19 +179,19 @@ If you want to get more detailed information, use the --verbose option.')
         // Get all files
         $files = [];
         if (!empty($customPaths)) {
-            $customPaths = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $customPaths, true);
+            $customPaths = GeneralUtility::trimExplode(',', $customPaths, true);
             foreach ($customPaths as $customPath) {
-                if (false === realpath(PATH_site . $customPath)
-                    || !GeneralUtility::isFirstPartOfStr(realpath(PATH_site . $customPath), realpath(PATH_site))) {
+                if (false === realpath(Environment::getPublicPath() . '/' . $customPath)
+                    || !GeneralUtility::isFirstPartOfStr(realpath(Environment::getPublicPath() . '/' . $customPath), realpath(Environment::getPublicPath()))) {
                     throw new \Exception('The path: "' . $customPath . '" is invalid', 1450086736);
                 }
-                $files = GeneralUtility::getAllFilesAndFoldersInPath($files, PATH_site . $customPath);
+                $files = GeneralUtility::getAllFilesAndFoldersInPath($files, Environment::getPublicPath() . '/' . $customPath);
             }
         } else {
-            $files = GeneralUtility::getAllFilesAndFoldersInPath($files, PATH_site . 'uploads/');
+            $files = GeneralUtility::getAllFilesAndFoldersInPath($files, Environment::getPublicPath() . '/uploads/');
         }
 
-        $files = GeneralUtility::removePrefixPathFromList($files, PATH_site);
+        $files = GeneralUtility::removePrefixPathFromList($files, Environment::getPublicPath() . '/');
 
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getQueryBuilderForTable('sys_refindex');
index 3ea622b..e0e1803 100644 (file)
@@ -21,6 +21,7 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Style\SymfonyStyle;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -169,7 +170,7 @@ If you want to get more detailed information, use the --verbose option.')
         // Traverse the references and check if the files exists
         while ($record = $result->fetch()) {
             $fileName = $record['ref_string'];
-            if (empty($record['softref_key']) && !@is_file(PATH_site . $fileName)) {
+            if (empty($record['softref_key']) && !@is_file(Environment::getPublicPath() . '/' . $fileName)) {
                 $missingReferences[$fileName][$record['hash']] = $this->formatReferenceIndexEntryToString($record);
             }
         }
@@ -202,7 +203,7 @@ If you want to get more detailed information, use the --verbose option.')
         // Traverse the references and check if the files exists
         while ($record = $result->fetch()) {
             $fileName = $record['ref_string'];
-            if (!@is_file(PATH_site . $fileName)) {
+            if (!@is_file(Environment::getPublicPath() . '/' . $fileName)) {
                 $missingReferences[] = $fileName . ' - ' . $record['hash'] . ' - ' . $this->formatReferenceIndexEntryToString($record);
             }
         }
index c6163d4..5bcd959 100644 (file)
@@ -21,6 +21,7 @@ use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Style\SymfonyStyle;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
@@ -195,7 +196,7 @@ If you want to get more detailed information, use the --verbose option.')
     /**
      * Find lost files in uploads/ folder
      *
-     * @return array an array of files (relative to PATH_site) that are not connected
+     * @return array an array of files (relative to Environment::getPublicPath()) that are not connected
      */
     protected function findAllReferencedRteImagesWithOriginals(): array
     {
@@ -234,9 +235,9 @@ If you want to get more detailed information, use the --verbose option.')
                     $original = 'RTEmagicP_' . preg_replace('/\\.[[:alnum:]]+$/', '', substr($filename, 10));
                     $original = substr($file, 0, -strlen($filename)) . $original;
                     $allRteImagesInUse[$file] = [
-                        'exists' => @is_file(PATH_site . $file),
+                        'exists' => @is_file(Environment::getPublicPath() . '/' . $file),
                         'original' => $original,
-                        'original_exists' => @is_file(PATH_site . $original),
+                        'original_exists' => @is_file(Environment::getPublicPath() . '/' . $original),
                         'count' => 0,
                         'softReferences' => []
                     ];
@@ -254,7 +255,7 @@ If you want to get more detailed information, use the --verbose option.')
      * Find all RTE files in uploads/ folder
      *
      * @param string $folder the name of the folder to start from
-     * @return array an array of files (relative to PATH_site) that are not connected
+     * @return array an array of files (relative to Environment::getPublicPath()) that are not connected
      */
     protected function findAllRteFilesInDirectory($folder = 'uploads/'): array
     {
@@ -262,8 +263,8 @@ If you want to get more detailed information, use the --verbose option.')
 
         // Get all files
         $files = [];
-        $files = GeneralUtility::getAllFilesAndFoldersInPath($files, PATH_site . $folder);
-        $files = GeneralUtility::removePrefixPathFromList($files, PATH_site);
+        $files = GeneralUtility::getAllFilesAndFoldersInPath($files, Environment::getPublicPath() . '/' . $folder);
+        $files = GeneralUtility::removePrefixPathFromList($files, Environment::getPublicPath() . '/');
 
         // Traverse files
         foreach ($files as $key => $value) {
@@ -328,9 +329,9 @@ If you want to get more detailed information, use the --verbose option.')
                     $dirPrefix = PathUtility::dirnameDuringBootstrap($fileName) . '/';
                     $rteOrigName = PathUtility::basenameDuringBootstrap($fileInfo['original']);
                     // If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
-                    if ($rteOrigName && strpos($dirPrefix, 'uploads/') === 0 && @is_dir(PATH_site . $dirPrefix)) {
+                    if ($rteOrigName && strpos($dirPrefix, 'uploads/') === 0 && @is_dir(Environment::getPublicPath() . '/' . $dirPrefix)) {
                         // From the "original" RTE filename, produce a new "original" destination filename which is unused.
-                        $origDestName = $fileProcObj->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
+                        $origDestName = $fileProcObj->getUniqueName($rteOrigName, Environment::getPublicPath() . '/' . $dirPrefix);
                         // Create copy file name
                         $pI = pathinfo($fileName);
                         $copyDestName = PathUtility::dirnameDuringBootstrap($origDestName) . '/RTEmagicC_' . substr(PathUtility::basenameDuringBootstrap($origDestName), 10) . '.' . $pI['extension'];
@@ -338,8 +339,8 @@ If you want to get more detailed information, use the --verbose option.')
                             $io->writeln('Copying file ' . PathUtility::basenameDuringBootstrap($fileName) . ' for record ' . $recordID . ' to ' . PathUtility::basenameDuringBootstrap($copyDestName));
                             if (!$dryRun) {
                                 // Making copies
-                                GeneralUtility::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
-                                GeneralUtility::upload_copy_move(PATH_site . $fileName, $copyDestName);
+                                GeneralUtility::upload_copy_move(Environment::getPublicPath() . '/' . $fileInfo['original'], $origDestName);
+                                GeneralUtility::upload_copy_move(Environment::getPublicPath() . '/' . $fileName, $copyDestName);
                                 clearstatcache();
                                 if (@is_file($copyDestName)) {
                                     $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class);
index 93ca8c8..21ad7aa 100644 (file)
                                <source>Search all filenames for pattern</source>
                        </trans-unit>
                        <trans-unit id="filesearch_description">
-                               <source>Will search recursively for filenames in the PATH_site (subdirs to the website path) matching a certain regex pattern.</source>
+                               <source>Will search recursively for filenames inside sub directories of the public web folder (PublicPath) matching a certain regex pattern.</source>
                        </trans-unit>
                        <trans-unit id="refindex">
                                <source>Check and update global reference index</source>
index 51b2004..ce4b76d 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Recycler\Task;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Scheduler\Task\AbstractTask;
@@ -210,7 +211,7 @@ class CleanerTask extends AbstractTask
 
         while ($row = $result->fetch()) {
             foreach ($fieldList as $fieldName) {
-                $uploadDir = PATH_site . $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['uploadfolder'] . '/';
+                $uploadDir = Environment::getPublicPath() . '/' . $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['uploadfolder'] . '/';
                 $fileList = GeneralUtility::trimExplode(',', $row[$fieldName]);
                 foreach ($fileList as $fileName) {
                     @unlink($uploadDir . $fileName);
index 396f414..ae57856 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Rsaauth;
  * The TYPO3 project - inspiring people to share!
  */
 use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -39,7 +40,7 @@ class BackendWarnings
             if ($path == '') {
                 // Path is empty
                 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_empty_directory');
-            } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($path)) {
+            } elseif (!GeneralUtility::isAbsPath($path)) {
                 // Path is not absolute
                 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_directory_not_absolute');
             } elseif (!@is_dir($path)) {
@@ -48,7 +49,7 @@ class BackendWarnings
             } elseif (!@is_writable($path)) {
                 // Directory is not writable
                 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_directory_not_writable');
-            } elseif (substr($path, 0, strlen(PATH_site)) == PATH_site) {
+            } elseif (substr($path, 0, strlen(Environment::getPublicPath())) === Environment::getPublicPath()) {
                 // Directory is inside the site root
                 $warnings['rsaauth'] = $lang->sL('LLL:EXT:rsaauth/Resources/Private/Language/locallang.xlf:hook_directory_inside_siteroot');
             }