[TASK] Replace beginsWith method with strpos to reduce execution time 34/50534/5
authorWouter Wolters <typo3@wouterwolters.nl>
Mon, 7 Nov 2016 20:20:57 +0000 (21:20 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Tue, 8 Nov 2016 11:58:11 +0000 (12:58 +0100)
Use the native PHP method strpos instead of StringUtility::beginsWith
method. The beginsWith method runtime compared to a simple strpos check
is much higher.

Resolves: #78602
Releases: master
Change-Id: I608ed791ddd770a8de493e0796387a18b22ff2ce
Reviewed-on: https://review.typo3.org/50534
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
33 files changed:
typo3/sysext/backend/Classes/Console/CliRequestHandler.php
typo3/sysext/backend/Classes/Controller/Wizard/TableController.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaColumnsProcessPlaceholders.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInputPlaceholders.php
typo3/sysext/backend/Classes/Form/Wizard/SuggestWizard.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Database/Schema/SchemaMigrator.php
typo3/sysext/core/Classes/Hooks/BackendUserGroupIntegrityCheck.php
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/core/Classes/Imaging/IconProvider/BitmapIconProvider.php
typo3/sysext/core/Classes/Imaging/IconProvider/SvgIconProvider.php
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Classes/Resource/ResourceCompressor.php
typo3/sysext/core/Classes/Tests/UnitTestCase.php
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Classes/Utility/PathUtility.php
typo3/sysext/felogin/Classes/Controller/FrontendLoginController.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/indexed_search/Classes/Domain/Repository/IndexSearchRepository.php
typo3/sysext/install/Classes/SystemEnvironment/DatabaseCheck.php
typo3/sysext/install/Classes/Updates/DatabaseCharsetUpdate.php
typo3/sysext/install/Classes/UpgradeAnalysis/DocumentationFile.php
typo3/sysext/linkvalidator/Classes/Linktype/FileLinktype.php
typo3/sysext/linkvalidator/Classes/Linktype/LinkHandler.php
typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php
typo3/sysext/rsaauth/Classes/RsaEncryptionDecoder.php
typo3/sysext/rtehtmlarea/Classes/Hook/Install/DeprecatedRteProperties.php
typo3/sysext/rtehtmlarea/Classes/Hook/Install/RteAcronymButtonRenamedToAbbreviation.php
typo3/sysext/scheduler/Classes/Task/OptimizeDatabaseTableAdditionalFieldProvider.php
typo3/sysext/scheduler/Classes/Task/OptimizeDatabaseTableTask.php

index 84548b0..ab310f1 100644 (file)
@@ -19,7 +19,6 @@ use Symfony\Component\Console\Output\ConsoleOutput;
 use TYPO3\CMS\Core\Console\RequestHandlerInterface;
 use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Command Line Interface Request Handler dealing with "cliKey"-based Commands from the cli_dispatch.phpsh script.
@@ -169,7 +168,7 @@ class CliRequestHandler implements RequestHandlerInterface
         if ($GLOBALS['BE_USER']->user['uid']) {
             throw new \RuntimeException('Another user was already loaded which is impossible in CLI mode!', 1476107444);
         }
-        if (!StringUtility::beginsWith($commandLineName, '_CLI_')) {
+        if (strpos($commandLineName, '_CLI_') !== 0) {
             throw new \RuntimeException('Module name, "' . $commandLineName . '", was not prefixed with "_CLI_"', 1476107445);
         }
         $userName = strtolower($commandLineName);
index 630a7d4..86d3092 100644 (file)
@@ -25,7 +25,6 @@ use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Script Class for rendering the Table Wizard
@@ -503,7 +502,7 @@ class TableController extends AbstractWizardController
             $cmd = '';
         }
         if ($cmd && MathUtility::canBeInterpretedAsInteger($kk)) {
-            if (StringUtility::beginsWith($cmd, 'row_')) {
+            if (strpos($cmd, 'row_') === 0) {
                 switch ($cmd) {
                     case 'row_remove':
                         unset($this->TABLECFG['c'][$kk]);
@@ -540,7 +539,7 @@ class TableController extends AbstractWizardController
                 }
                 ksort($this->TABLECFG['c']);
             }
-            if (StringUtility::beginsWith($cmd, 'col_')) {
+            if (strpos($cmd, 'col_') === 0) {
                 foreach ($this->TABLECFG['c'] as $cAK => $value) {
                     switch ($cmd) {
                         case 'col_remove':
index b200aaa..7f2b1a7 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Backend\Form\FormDataProvider;
 
 use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Mark columns that are used by input placeholders for further processing
@@ -43,7 +42,7 @@ class TcaColumnsProcessPlaceholders implements FormDataProviderInterface
             }
 
             // Process __row|field type placeholders
-            if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], '__row|')) {
+            if (strpos($fieldConfig['config']['placeholder'], '__row|') === 0) {
                 // split field names into array and remove the __row indicator
                 $fieldNameArray = array_slice(
                     GeneralUtility::trimExplode('|', $fieldConfig['config']['placeholder'], true),
index 2ef165e..14dac9a 100644 (file)
@@ -19,7 +19,6 @@ use TYPO3\CMS\Backend\Form\FormDataGroup\TcaInputPlaceholderRecord;
 use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Lang\LanguageService;
 
 /**
@@ -49,7 +48,7 @@ class TcaInputPlaceholders implements FormDataProviderInterface
             }
 
             // Resolve __row|field type placeholders
-            if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], '__row|')) {
+            if (strpos($fieldConfig['config']['placeholder'], '__row|') === 0) {
                 // split field names into array and remove the __row indicator
                 $fieldNameArray = array_slice(
                     GeneralUtility::trimExplode('|', $fieldConfig['config']['placeholder'], true),
@@ -59,7 +58,7 @@ class TcaInputPlaceholders implements FormDataProviderInterface
             }
 
             // Resolve placeholders from language files
-            if (StringUtility::beginsWith($fieldConfig['config']['placeholder'], 'LLL:')) {
+            if (strpos($fieldConfig['config']['placeholder'], 'LLL:') === 0) {
                 $result['processedTca']['columns'][$fieldName]['config']['placeholder'] = $this->getLanguageService()->sL($fieldConfig['config']['placeholder']);
             }
 
index d40ef87..d8ea1e5 100644 (file)
@@ -22,7 +22,6 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
 use TYPO3\CMS\Lang\LanguageService;
 
@@ -384,7 +383,7 @@ class SuggestWizard
     protected function isRelevantFlexField($fieldName)
     {
         return !(
-            StringUtility::beginsWith($fieldName, 'ID-') ||
+            strpos($fieldName, 'ID-') === 0 ||
             $fieldName === 'lDEF' ||
             $fieldName === 'vDEF' ||
             $fieldName === 'data' ||
index bd930a6..d1763e5 100644 (file)
@@ -40,7 +40,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Lang\LanguageService;
@@ -1204,7 +1203,7 @@ class BackendUtility
                     $includeTsConfigFileList = GeneralUtility::trimExplode(',', $v['tsconfig_includes'], true);
                     // Traversing list
                     foreach ($includeTsConfigFileList as $key => $includeTsConfigFile) {
-                        if (StringUtility::beginsWith($includeTsConfigFile, 'EXT:')) {
+                        if (strpos($includeTsConfigFile, 'EXT:') === 0) {
                             list($includeTsConfigFileExtensionKey, $includeTsConfigFilename) = explode(
                                 '/',
                                 substr($includeTsConfigFile, 4),
index 00c6140..2eedd3d 100644 (file)
@@ -29,7 +29,6 @@ use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Schema\Parser\Parser;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Helper methods to handle SQL files and transform them into individual statements
@@ -800,7 +799,7 @@ class SchemaMigrator
             // Skip tables that are not being renamed or where the new name isn't prefixed
             // with the deletion marker.
             if ($tableDiff->getNewName() === false
-                || !StringUtility::beginsWith($tableDiff->getNewName()->getName(), $this->deletedPrefix)
+                || strpos($tableDiff->getNewName()->getName(), $this->deletedPrefix) !== 0
             ) {
                 continue;
             }
@@ -1026,7 +1025,7 @@ class SchemaMigrator
         Connection $connection
     ): SchemaDiff {
         foreach ($schemaDiff->removedTables as $index => $removedTable) {
-            if (StringUtility::beginsWith($removedTable->getName(), $this->deletedPrefix)) {
+            if (strpos($removedTable->getName(), $this->deletedPrefix) === 0) {
                 continue;
             }
             $tableDiff = GeneralUtility::makeInstance(
@@ -1068,7 +1067,7 @@ class SchemaMigrator
             }
 
             foreach ($changedTable->removedColumns as $columnIndex => $removedColumn) {
-                if (StringUtility::beginsWith($removedColumn->getName(), $this->deletedPrefix)) {
+                if (strpos($removedColumn->getName(), $this->deletedPrefix) === 0) {
                     continue;
                 }
 
@@ -1166,7 +1165,7 @@ class SchemaMigrator
                 // If the tablename has a deleted prefix strip it of before comparing
                 // it against the list of valid table names so that drop operations
                 // don't get removed.
-                if (StringUtility::beginsWith($tableName, $this->deletedPrefix)) {
+                if (strpos($tableName, $this->deletedPrefix) === 0) {
                     $tableName = substr($tableName, strlen($this->deletedPrefix));
                 }
                 return in_array($tableName, $validTableNames, true)
@@ -1249,7 +1248,7 @@ class SchemaMigrator
     protected function getTableOptions(Connection $connection, array $tableNames): array
     {
         $tableOptions = [];
-        if (!StringUtility::beginsWith($connection->getServerVersion(), 'MySQL')) {
+        if (strpos($connection->getServerVersion(), 'MySQL') !== 0) {
             foreach ($tableNames as $tableName) {
                 $tableOptions[$tableName] = [];
             }
index 8f5487d..fd056c6 100644 (file)
@@ -20,7 +20,6 @@ use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Lang\LanguageService;
 
 /**
@@ -44,7 +43,7 @@ class BackendUserGroupIntegrityCheck
         $backendUserGroup = BackendUtility::getRecord($table, $id, 'explicit_allowdeny');
         $explicitAllowDenyFields = GeneralUtility::trimExplode(',', $backendUserGroup['explicit_allowdeny']);
         foreach ($explicitAllowDenyFields as $value) {
-            if (StringUtility::beginsWith($value, 'tt_content:list_type:')) {
+            if ($value !== '' && strpos($value, 'tt_content:list_type:') === 0) {
                 if (!in_array('tt_content:CType:list:ALLOW', $explicitAllowDenyFields, true)) {
                     /** @var $flashMessage FlashMessage */
                     $flashMessage = GeneralUtility::makeInstance(
index ceb53c6..9746d06 100644 (file)
@@ -19,7 +19,6 @@ use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Resource;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Frontend\Service\TypoLinkCodecService;
 
 /**
@@ -573,7 +572,7 @@ class RteHtmlParser extends HtmlParser
                 } else {
                     // Check for FAL link-handler keyword:
                     list($linkHandlerKeyword, $linkHandlerValue) = explode(':', trim($link_param), 2);
-                    if ($linkHandlerKeyword === 'file' && !StringUtility::beginsWith($link_param, 'file://')) {
+                    if ($linkHandlerKeyword === 'file' && strpos($link_param, 'file://') !== 0) {
                         $href = $siteUrl . '?' . $linkHandlerKeyword . ':' . rawurlencode($linkHandlerValue);
                     } else {
                         $fileChar = (int)strpos($link_param, '/');
index adddca0..bae1fb0 100644 (file)
@@ -18,7 +18,6 @@ use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconProviderInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Class BitmapIconProvider provides icons that are classic <img> tags using bitmaps as source
@@ -51,7 +50,7 @@ class BitmapIconProvider implements IconProviderInterface
 
         $source = $options['source'];
 
-        if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) {
+        if (strpos($source, 'EXT:') === 0 || strpos($source, '/') !== 0) {
             $source = GeneralUtility::getFileAbsFileName($source);
         }
         $source = PathUtility::getAbsoluteWebPath($source);
@@ -73,7 +72,7 @@ class BitmapIconProvider implements IconProviderInterface
 
         $source = $options['source'];
 
-        if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) {
+        if (strpos($source, 'EXT:') === 0 || strpos($source, '/') !== 0) {
             $source = GeneralUtility::getFileAbsFileName($source);
         }
 
index 66ed75d..df4c203 100644 (file)
@@ -18,7 +18,6 @@ use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconProviderInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Class SvgIconProvider provides icons that are classic <img> tags using vectors as source
@@ -51,7 +50,7 @@ class SvgIconProvider implements IconProviderInterface
 
         $source = $options['source'];
 
-        if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) {
+        if (strpos($source, 'EXT:') === 0 || strpos($source, '/') !== 0) {
             $source = GeneralUtility::getFileAbsFileName($source);
         }
 
@@ -73,7 +72,7 @@ class SvgIconProvider implements IconProviderInterface
 
         $source = $options['source'];
 
-        if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) {
+        if (strpos($source, 'EXT:') === 0 || strpos($source, '/') !== 0) {
             $source = GeneralUtility::getFileAbsFileName($source);
         }
 
index d304539..fa03209 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Core\Migrations;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Migrate TCA from old to new syntax. Used in bootstrap and Flex Form Data Structures.
@@ -433,12 +432,12 @@ class TcaMigration
                             $path = implode('/', $pathParts);
                             // If the path starts with ext/ or sysext/ migrate it
                             if (
-                                StringUtility::beginsWith($itemConfig[2], 'ext/')
-                                || StringUtility::beginsWith($itemConfig[2], 'sysext/')
+                                strpos($itemConfig[2], 'ext/') === 0
+                                || strpos($itemConfig[2], 'sysext/') === 0
                             ) {
                                 $this->messages[] = '[' . $tcaPath . '] ext/ or sysext/ within the path (' . $path . ') in items array is deprecated, use EXT: reference';
                                 $itemConfig[2] = 'EXT:' . $path;
-                            } elseif (StringUtility::beginsWith($itemConfig[2], 'i/')) {
+                            } elseif (strpos($itemConfig[2], 'i/') === 0) {
                                 $this->messages[] = '[' . $tcaPath . '] i/ within the path (' . $path . ') in items array is deprecated, use EXT: reference';
                                 $itemConfig[2] = 'EXT:t3skin/icons/gfx/' . $itemConfig[2];
                             }
@@ -490,7 +489,7 @@ class TcaMigration
             if (!isset($tableDefinition['ctrl']['iconfile'])) {
                 continue;
             }
-            if (StringUtility::beginsWith($tableDefinition['ctrl']['iconfile'], '../typo3conf/ext/')) {
+            if (strpos($tableDefinition['ctrl']['iconfile'], '../typo3conf/ext/') === 0) {
                 $tableDefinition['ctrl']['iconfile'] = str_replace('../typo3conf/ext/', 'EXT:', $tableDefinition['ctrl']['iconfile']);
                 $tcaPath = implode('.', [$table, 'ctrl', 'iconfile']);
                 $this->messages[] = '[' . $tcaPath . '] relative path to ../typo3conf/ext/ is deprecated, use EXT: instead';
index 08aa05e..91359ef 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Core\Resource;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Compressor
@@ -284,7 +283,7 @@ class ResourceCompressor
                 $filename = PathUtility::stripPathSitePrefix($filenameAbsolute);
                 $contents = file_get_contents($filenameAbsolute);
                 // remove any UTF-8 byte order mark (BOM) from files
-                if (StringUtility::beginsWith($contents, "\xEF\xBB\xBF")) {
+                if (strpos($contents, "\xEF\xBB\xBF") === 0) {
                     $contents = substr($contents, 3);
                 }
                 // only fix paths if files aren't already in typo3temp (already processed)
index c0bad84..b6d6937 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Core\Tests;
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Base test case for unit tests.
@@ -81,7 +80,7 @@ abstract class UnitTestCase extends BaseTestCase
             if (!GeneralUtility::validPathStr($absoluteFileName)) {
                 throw new \RuntimeException('tearDown() cleanup: Filename contains illegal characters', 1410633087);
             }
-            if (!StringUtility::beginsWith($absoluteFileName, PATH_site . 'typo3temp/var/')) {
+            if (strpos($absoluteFileName, PATH_site . 'typo3temp/var/') !== 0) {
                 throw new \RuntimeException(
                     'tearDown() cleanup:  Files to delete must be within typo3temp/var/',
                     1410633412
index f98690d..33c8806 100644 (file)
@@ -20,7 +20,6 @@ use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * The TypoScript parser
@@ -495,7 +494,7 @@ class TypoScriptParser
                             $this->lastComment .= rtrim($line) . LF;
                         }
                     }
-                    if (StringUtility::beginsWith($line, '### ERROR')) {
+                    if (strpos($line, '### ERROR') === 0) {
                         $this->error(substr($line, 11));
                     }
                 }
@@ -874,7 +873,7 @@ class TypoScriptParser
                 // load default TypoScript for content rendering templates like
                 // css_styled_content if those have been included through f.e.
                 // <INCLUDE_TYPOSCRIPT: source="FILE:EXT:css_styled_content/static/setup.txt">
-                if (StringUtility::beginsWith(strtolower($filename), 'ext:')) {
+                if (strpos(strtolower($filename), 'ext:') === 0) {
                     $filePointerPathParts = explode('/', substr($filename, 4));
 
                     // remove file part, determine whether to load setup or constants
index 89c4444..adb5cd5 100644 (file)
@@ -28,7 +28,6 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -1212,7 +1211,7 @@ class TemplateService
     protected function mergeConstantsFromIncludedTsConfigFiles($filesToInclude, $TSdataArray)
     {
         foreach ($filesToInclude as $key => $file) {
-            if (!StringUtility::beginsWith($file, 'EXT:')) {
+            if (strpos($file, 'EXT:') !== 0) {
                 continue;
             }
 
@@ -1246,8 +1245,8 @@ class TemplateService
     {
         if (is_array($setupArray)) {
             foreach ($setupArray as $key => $val) {
-                if ($prefix || !StringUtility::beginsWith($key, 'TSConstantEditor')) {
-                    // We don't want 'TSConstantEditor' in the flattend setup on the first level (190201)
+                if ($prefix || strpos($key, 'TSConstantEditor') !== 0) {
+                    // We don't want 'TSConstantEditor' in the flattened setup on the first level (190201)
                     if (is_array($val)) {
                         $this->flattenSetup($val, $prefix . $key);
                     } else {
index 427106a..3eb14bb 100644 (file)
@@ -433,7 +433,7 @@ class ExtensionManagementUtility
                 }
                 if (
                     isset($fieldArrayWithOptions[$fieldNumber + 1])
-                    && StringUtility::beginsWith($fieldArrayWithOptions[$fieldNumber + 1],  '--palette--')
+                    && strpos($fieldArrayWithOptions[$fieldNumber + 1],  '--palette--') === 0
                 ) {
                     // Match for $field and next field is a palette - add fields to this one
                     $paletteName = GeneralUtility::trimExplode(';', $fieldArrayWithOptions[$fieldNumber + 1]);
index a7e66c9..ec102dd 100644 (file)
@@ -40,7 +40,7 @@ class PathUtility
     public static function getAbsoluteWebPath($targetPath)
     {
         if (self::isAbsolutePath($targetPath)) {
-            if (StringUtility::beginsWith($targetPath, PATH_site)) {
+            if (strpos($targetPath, PATH_site) === 0) {
                 $targetPath = self::stripPathSitePrefix($targetPath);
                 if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) {
                     $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
index c71a7fc..2e60383 100644 (file)
@@ -19,7 +19,6 @@ use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Plugin 'Website User Login' for the 'felogin' extension.
@@ -1042,8 +1041,8 @@ class FrontendLoginController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
     {
         $urlWithoutSchema = preg_replace('#^https?://#', '', $url);
         $siteUrlWithoutSchema = preg_replace('#^https?://#', '', GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
-        return StringUtility::beginsWith($urlWithoutSchema . '/', GeneralUtility::getIndpEnv('HTTP_HOST') . '/')
-            && StringUtility::beginsWith($urlWithoutSchema, $siteUrlWithoutSchema);
+        return strpos($urlWithoutSchema . '/', GeneralUtility::getIndpEnv('HTTP_HOST') . '/') === 0
+            && strpos($urlWithoutSchema, $siteUrlWithoutSchema) === 0;
     }
 
     /**
index 183cef9..26ba1fb 100644 (file)
@@ -4771,7 +4771,7 @@ class ContentObjectRenderer
                 // tags
                 $len = strcspn(substr($theValue, $pointer), '>') + 1;
                 $data = substr($theValue, $pointer, $len);
-                if (StringUtility::endsWith($data, '/>') && !StringUtility::beginsWith($data, '<link ')) {
+                if (StringUtility::endsWith($data, '/>') && strpos($data, '<link ') !== 0) {
                     $tagContent = substr($data, 1, -2);
                 } else {
                     $tagContent = substr($data, 1, -1);
@@ -5709,7 +5709,7 @@ class ContentObjectRenderer
         }
 
         // Resolve FAL-api "file:UID-of-sys_file-record" and "file:combined-identifier"
-        if ($linkHandlerKeyword === 'file' && !StringUtility::beginsWith($linkParameterParts['url'], 'file://')) {
+        if ($linkHandlerKeyword === 'file' && strpos($linkParameterParts['url'], 'file://') !== 0) {
             try {
                 $fileOrFolderObject = $this->getResourceFactory()->retrieveFileOrFolderObject($linkHandlerValue);
                 // Link to a folder or file
@@ -5849,7 +5849,7 @@ class ContentObjectRenderer
                     $linkLocation = $fileOrFolderObject->getPublicUrl();
                     // Setting title if blank value to link
                     $linkText = $this->parseFallbackLinkTextIfLinkTextIsEmpty($linkText, rawurldecode($linkLocation));
-                    $linkLocation = (!StringUtility::beginsWith($linkLocation, '/') ? $tsfe->absRefPrefix : '') . $linkLocation;
+                    $linkLocation = (strpos($linkLocation, '/') !== 0 ? $tsfe->absRefPrefix : '') . $linkLocation;
                     $this->lastTypoLinkUrl = $this->processUrl(UrlProcessorInterface::CONTEXT_FILE, $linkLocation, $conf);
                     $this->lastTypoLinkUrl = $this->forceAbsoluteUrl($this->lastTypoLinkUrl, $conf);
 
@@ -6112,7 +6112,7 @@ class ContentObjectRenderer
                     $linkLocation = $linkDetails['file'];
                     // Setting title if blank value to link
                     $linkText = $this->parseFallbackLinkTextIfLinkTextIsEmpty($linkText, rawurldecode($linkLocation));
-                    $linkLocation = (!StringUtility::beginsWith($linkLocation, '/') ? $tsfe->absRefPrefix : '') . $linkLocation;
+                    $linkLocation = (strpos($linkLocation, '/') !== 0 ? $tsfe->absRefPrefix : '') . $linkLocation;
                     $this->lastTypoLinkUrl = $this->processUrl(UrlProcessorInterface::CONTEXT_FILE, $linkLocation, $conf);
                     $this->lastTypoLinkUrl = $this->forceAbsoluteUrl($this->lastTypoLinkUrl, $conf);
                     if (empty($target)) {
@@ -7782,7 +7782,7 @@ class ContentObjectRenderer
         }
 
         // Static_* tables are allowed to be fetched from root page
-        if (StringUtility::beginsWith($table, 'static_')) {
+        if (strpos($table, 'static_') === 0) {
             $pid_uid_flag++;
         }
 
index e0fd2bd..ac30f0b 100644 (file)
@@ -44,7 +44,6 @@ use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Http\UrlHandlerInterface;
@@ -4175,7 +4174,7 @@ class TypoScriptFrontendController
             // This is a hack to work around ___FILE___ resolving symbolic links
             $PATH_site_real = dirname(realpath(PATH_site . 'typo3')) . '/';
             $file = $trace[0]['file'];
-            if (StringUtility::beginsWith($file, $PATH_site_real)) {
+            if (strpos($file, $PATH_site_real) === 0) {
                 $file = str_replace($PATH_site_real, '', $file);
             } else {
                 $file = str_replace(PATH_site, '', $file);
index 8656c6c..ea6dc5b 100644 (file)
@@ -22,7 +22,6 @@ use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\IndexedSearch\Indexer;
 use TYPO3\CMS\IndexedSearch\Utility;
 
@@ -342,7 +341,7 @@ class IndexSearchRepository
     protected function getResultRows_SQLpointerMysqlFulltext($searchWordsArray, $freeIndexUid = -1)
     {
         $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('index_fulltext');
-        if (!StringUtility::beginsWith($connection->getServerVersion(), 'MySQL')) {
+        if (strpos($connection->getServerVersion(), 'MySQL') !== 0) {
             throw new \RuntimeException(
                 'Extension indexed_search is configured to use mysql fulltext, but table \'index_fulltext\''
                 . ' is running on a different DBMS.',
index 5fab15f..df6122b 100644 (file)
@@ -18,7 +18,6 @@ use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Install\Status;
 
 /**
@@ -51,7 +50,7 @@ class DatabaseCheck
         $statusArray = [];
         $defaultConnection = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
-        if (!StringUtility::beginsWith($defaultConnection->getServerVersion(), 'MySQL')) {
+        if (strpos($defaultConnection->getServerVersion(), 'MySQL') !== 0) {
             return $statusArray;
         }
         $statusArray[] = $this->checkMysqlVersion($defaultConnection);
@@ -135,7 +134,7 @@ class DatabaseCheck
             ->execute()
             ->fetchColumn();
         // also allow utf8mb4
-        if (!StringUtility::beginsWith($defaultDatabaseCharset, 'utf8')) {
+        if (strpos($defaultDatabaseCharset, 'utf8') !== 0) {
             $status = new Status\ErrorStatus();
             $status->setTitle('MySQL database character set check failed');
             $status->setMessage(
index e8f2b11..6f03e86 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Install\Updates;
 use Doctrine\DBAL\DBALException;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Move "wizard done" flags to system registry
@@ -49,7 +48,7 @@ class DatabaseCharsetUpdate extends AbstractUpdate
         WARNING: This will NOT convert any existing data.';
 
         // check if database charset is utf-8, also allows utf8mb4
-        if (!StringUtility::beginsWith($this->getDefaultDatabaseCharset(), 'utf8')) {
+        if (strpos($this->getDefaultDatabaseCharset(), 'utf8') !== 0) {
             $result = true;
         } else {
             $this->markWizardAsDone();
@@ -97,7 +96,7 @@ class DatabaseCharsetUpdate extends AbstractUpdate
         $connection = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
 
-        return StringUtility::beginsWith($connection->getServerVersion(), 'MySQL');
+        return strpos($connection->getServerVersion(), 'MySQL') === 0;
     }
 
     /**
index 7cef249..75cb22a 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Install\UpgradeAnalysis;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Provide information about documentation files
@@ -87,7 +86,7 @@ class DocumentationFile
     protected function extractTagsFromFile(array $file): array
     {
         foreach ($file as $line) {
-            if (StringUtility::beginsWith($line, '.. index::')) {
+            if (strpos($line, '.. index::') === 0) {
                 $tagString = substr($line, strlen('.. index:: '));
                 return GeneralUtility::trimExplode(',', $tagString, true);
             }
@@ -124,7 +123,7 @@ class DocumentationFile
     protected function extractHeadline(array $lines): string
     {
         $index = 0;
-        while (StringUtility::beginsWith($lines[$index], '..') || StringUtility::beginsWith($lines[$index], '==')) {
+        while (strpos($lines[$index], '..') === 0 || strpos($lines[$index], '==') === 0) {
             $index++;
         }
         return trim($lines[$index]);
index 6b1599b..1fe75fe 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
 use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * This class provides Check File Links plugin implementation
@@ -34,7 +33,7 @@ class FileLinktype extends AbstractLinktype
      */
     public function fetchType($value, $type, $key)
     {
-        if (StringUtility::beginsWith(strtolower($value['tokenValue']), 'file:')) {
+        if (strpos(strtolower($value['tokenValue']), 'file:') === 0) {
             $type = 'file';
         }
         return $type;
index 7ae42f1..a8f5fc0 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Linkvalidator\Linktype;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * This class provides Check Link Handler plugin implementation
@@ -109,7 +108,7 @@ class LinkHandler extends AbstractLinktype
      */
     public function fetchType($value, $type, $key)
     {
-        if ($value['type'] === 'string' && StringUtility::beginsWith(strtolower($value['tokenValue']), 'record:')) {
+        if ($value['type'] === 'string' && strpos(strtolower($value['tokenValue']), 'record:') === 0) {
             $type = 'linkhandler';
         }
         return $type;
index 1ce737a..987e7f0 100644 (file)
@@ -22,7 +22,6 @@ use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Reports\Status as ReportStatus;
 use TYPO3\CMS\Reports\StatusProviderInterface;
@@ -277,7 +276,7 @@ class ConfigurationStatus implements StatusProviderInterface
         $connection = GeneralUtility::makeInstance(ConnectionPool::class)
             ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
 
-        return StringUtility::beginsWith($connection->getServerVersion(), 'MySQL');
+        return strpos($connection->getServerVersion(), 'MySQL') === 0;
     }
 
     /**
@@ -306,7 +305,7 @@ class ConfigurationStatus implements StatusProviderInterface
         $severity = ReportStatus::OK;
         $statusValue = $this->getLanguageService()->getLL('status_ok');
         // also allow utf8mb4
-        if (!StringUtility::beginsWith($defaultDatabaseCharset, 'utf8')) {
+        if (strpos($defaultDatabaseCharset, 'utf8') !== 0) {
             // If the default character set is e.g. latin1, BUT all tables in the system are UTF-8,
             // we assume that TYPO3 has the correct charset for adding tables, and everything is fine
             $nonUtf8TableCollationsFound = $queryBuilder->select('table_collation')
index 98a245b..04fbb0f 100644 (file)
@@ -14,8 +14,6 @@ namespace TYPO3\CMS\Rsaauth;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Utility\StringUtility;
-
 /**
  * This class decodes rsa protected data
  */
@@ -76,7 +74,7 @@ class RsaEncryptionDecoder implements \TYPO3\CMS\Core\SingletonInterface
                 continue;
             }
 
-            if (!StringUtility::beginsWith($value, 'rsa:')) {
+            if (strpos($value, 'rsa:') !== 0) {
                 continue;
             }
 
index a586080..2ede937 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Rtehtmlarea\Hook\Install;
 use Doctrine\DBAL\DBALException;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Install\Updates\AbstractUpdate;
 
 /**
@@ -210,7 +209,7 @@ class DeprecatedRteProperties extends AbstractUpdate
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
         $queryBuilder->getRestrictions()->removeAll();
 
-        $isMySQL = StringUtility::beginsWith($queryBuilder->getConnection()->getServerVersion(), 'MySQL');
+        $isMySQL = strpos($queryBuilder->getConnection()->getServerVersion(), 'MySQL') === 0;
 
         $constraints = [];
         foreach (array_merge($this->replacementRteProperties, $this->useInsteadRteProperties, $this->doubleReplacementRteProperties) as $deprecatedRteProperty => $_) {
index 8e6cb54..ef58bba 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Rtehtmlarea\Hook\Install;
 use Doctrine\DBAL\DBALException;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Install\Updates\AbstractUpdate;
 
 /**
@@ -115,7 +114,7 @@ class RteAcronymButtonRenamedToAbbreviation extends AbstractUpdate
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
         $queryBuilder->getRestrictions()->removeAll();
 
-        $isMySQL = StringUtility::beginsWith($queryBuilder->getConnection()->getServerVersion(), 'MySQL');
+        $isMySQL = strpos($queryBuilder->getConnection()->getServerVersion(), 'MySQL') === 0;
         if ($isMySQL) {
             $whereClause = $queryBuilder->expr()->comparison(
                 $queryBuilder->quoteIdentifier('TSconfig'),
index 6c3483f..0257d45 100644 (file)
@@ -18,7 +18,6 @@ use TYPO3\CMS\Core\Database\Connection;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
 use TYPO3\CMS\Scheduler\Controller\SchedulerModuleController;
 
@@ -191,7 +190,7 @@ class OptimizeDatabaseTableAdditionalFieldProvider implements AdditionalFieldPro
     protected function getOptimizableTablesForConnection(Connection $connection, array $tableNames = []): array
     {
         // Return empty list if the database platform is not MySQL
-        if (!StringUtility::beginsWith($connection->getServerVersion(), 'MySQL')) {
+        if (strpos($connection->getServerVersion(), 'MySQL') !== 0) {
             return [];
         }
 
index c7f22d3..401ab3a 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Scheduler\Task;
 use Doctrine\DBAL\DBALException;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Perform OPTIMIZE TABLE SQL statements
@@ -46,7 +45,7 @@ class OptimizeDatabaseTableTask extends AbstractTask
         foreach ($this->selectedTables as $tableName) {
             $connection = $connectionPool->getConnectionForTable($tableName);
 
-            if (StringUtility::beginsWith($connection->getServerVersion(), 'MySQL')) {
+            if (strpos($connection->getServerVersion(), 'MySQL') === 0) {
                 try {
                     $connection->exec('OPTIMIZE TABLE ' . $connection->quoteIdentifier($tableName));
                 } catch (DBALException $e) {