[FEATURE] Introduce internal uniqueId generator 44/43244/3
authorNicole Cordes <typo3@cordes.co>
Sat, 12 Sep 2015 14:57:34 +0000 (16:57 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 12 Sep 2015 21:54:09 +0000 (23:54 +0200)
This patch add the function StringUtility::getUniqueId() which gets
an unique id (with using more entropy for Windows users) and removes
the included dot to be able to use the generated id in HTML as the dot
is an invalid character in some tag attributes e.g. id.

Resolves: #69730
Releases: master
Change-Id: Ic8a83df0a8b02f6778f0f5588d237379d909b59e
Reviewed-on: http://review.typo3.org/43244
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
36 files changed:
typo3/sysext/backend/Classes/Form/Container/FlexFormSectionContainer.php
typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php
typo3/sysext/backend/Classes/Form/Element/ImageManipulationElement.php
typo3/sysext/backend/Classes/Form/Element/InputElement.php
typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php
typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
typo3/sysext/backend/Classes/Form/Element/TextElement.php
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseUniqueUidNewRow.php
typo3/sysext/backend/Classes/Form/InlineRelatedRecordResolver.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/core/Classes/Cache/Backend/FileBackend.php
typo3/sysext/core/Classes/Cache/Backend/RedisBackend.php
typo3/sysext/core/Classes/Cache/Backend/SimpleFileBackend.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Database/DatabaseConnection.php
typo3/sysext/core/Classes/Database/QueryGenerator.php
typo3/sysext/core/Classes/Package/PackageManager.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Classes/Utility/StringUtility.php
typo3/sysext/core/Documentation/Changelog/master/Feature-69730-IntroduceUniqueIdGenerator.rst [new file with mode: 0644]
typo3/sysext/core/Tests/BaseTestCase.php
typo3/sysext/core/Tests/Functional/DataHandling/Framework/ActionService.php
typo3/sysext/core/Tests/Unit/Utility/StringUtilityTest.php
typo3/sysext/form/Tests/Unit/Domain/Model/Attribute/AttributesAttributeTest.php
typo3/sysext/impexp/Classes/ImportExport.php
typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php
typo3/sysext/install/Classes/FolderStructure/DirectoryNode.php
typo3/sysext/install/Classes/Service/CoreUpdateService.php
typo3/sysext/mediace/Classes/ContentObject/FlowPlayerContentObject.php
typo3/sysext/mediace/Classes/ContentObject/QuicktimeObjectContentObject.php
typo3/sysext/mediace/Classes/ContentObject/ShockwaveFlashObjectContentObject.php
typo3/sysext/rsaauth/Classes/Backend/CommandLineBackend.php
typo3/sysext/rsaauth/Classes/Form/Element/RsaInputElement.php
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php

index f15cd5e..cdd1e39 100644 (file)
@@ -14,10 +14,10 @@ namespace TYPO3\CMS\Backend\Form\Container;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Lang\LanguageService;
 
@@ -110,7 +110,7 @@ class FlexFormSectionContainer extends AbstractContainer {
                        $options['renderType'] = 'flexFormContainerContainer';
                        $flexFormContainerContainerTemplateResult = $this->nodeFactory->create($options)->render();
 
-                       $uniqueId = str_replace('.', '', uniqid('idvar', TRUE));
+                       $uniqueId = StringUtility::getUniqueId('idvar');
                        $identifierPrefixJs = 'replace(/' . $flexFormFieldIdentifierPrefix . '-/g,"' . $flexFormFieldIdentifierPrefix . '-"+' . $uniqueId . '+"-")';
                        $identifierPrefixJs .= '.replace(/(tceforms-(datetime|date)field-)/g,"$1" + (new Date()).getTime())';
 
index 096eb81..1fd39a8 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Backend\Form\Element;
 use TYPO3\CMS\Backend\Form\FormDataCompiler;
 use TYPO3\CMS\Backend\Form\FormDataGroup\OnTheFly;
 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSelectItems;
-use TYPO3\CMS\Backend\Form\FormEngine;
 use TYPO3\CMS\Backend\Template\DocumentTemplate;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
@@ -25,8 +24,8 @@ use TYPO3\CMS\Lang\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Backend\Form\Wizard\SuggestWizard;
 use TYPO3\CMS\Backend\Form\Wizard\ValueSliderWizard;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -434,7 +433,7 @@ abstract class AbstractFormElement extends AbstractNode {
                                        }
                                        $otherWizards[] =
                                                '<select' .
-                                                       ' id="' . str_replace('.', '', uniqid('tceforms-select-', TRUE)) . '"' .
+                                                       ' id="' . StringUtility::getUniqueId('tceforms-select-') . '"' .
                                                        ' class="form-control tceforms-select tceforms-wizardselect"' .
                                                        ' name="_WIZARD' . $fName . '"' .
                                                        ' onchange="' . htmlspecialchars($assignValue . ';this.blur();this.selectedIndex=0;' . implode('', $fieldChangeFunc)) . '"'.
@@ -563,7 +562,7 @@ abstract class AbstractFormElement extends AbstractNode {
                        : $params['size'];
                if (!$selector) {
                        $isMultiple = $params['maxitems'] != 1 && $params['size'] != 1;
-                       $selector = '<select id="' . str_replace('.', '', uniqid('tceforms-multiselect-', TRUE)) . '" '
+                       $selector = '<select id="' . StringUtility::getUniqueId('tceforms-multiselect-') . '" '
                                . ($params['noList'] ? 'style="display: none"' : 'size="' . $sSize . '" class="form-control tceforms-multiselect"')
                                . ($isMultiple ? ' multiple="multiple"' : '')
                                . ' name="' . $fName . '_list" ' . $this->getValidationDataAsDataAttribute($config) . $onFocus . $params['style'] . $disabled . '>' . implode('', $opt)
index 7a17338..2128478 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Extbase\Utility\ArrayUtility;
 
 /**
@@ -96,7 +97,7 @@ class ImageManipulationElement extends AbstractFormElement {
                                $config['ratios'][$ratio] = $languageService->sL($label, TRUE);
                        }
 
-                       $formFieldId = str_replace('.', '', uniqid('formengine-image-manipulation-', TRUE));
+                       $formFieldId = StringUtility::getUniqueId('formengine-image-manipulation-');
                        $wizardData = array(
                                'file' => $file->getUid(),
                                'zoom' => $config['enableZoom'] ? '1' : '0',
index 8d70af8..b1dce30 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Generation of TCEform elements of the type "input"
@@ -168,7 +169,7 @@ class InputElement extends AbstractFormElement {
                // calculate attributes
                $attributes['data-formengine-validation-rules'] = $this->getValidationDataAsJsonString($config);
                $attributes['data-formengine-input-params'] = json_encode($paramsList);
-               $attributes['id'] = str_replace('.', '', uniqid('formengine-input-', TRUE));
+               $attributes['id'] = StringUtility::getUniqueId('formengine-input-');
                $attributes['name'] = $parameterArray['itemFormElName'] . '_hr';
                $attributes['value'] = '';
                if (isset($config['max']) && (int)$config['max'] > 0) {
index 38ddb15..df4bff0 100644 (file)
@@ -16,7 +16,7 @@ namespace TYPO3\CMS\Backend\Form\Element;
 
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
 
@@ -145,7 +145,7 @@ class SelectCheckBoxElement extends AbstractFormElement {
 
                                        // Build item array
                                        $groups[$currentGroup]['items'][] = array(
-                                               'id' => str_replace('.', '', uniqid('select_checkbox_row_', TRUE)),
+                                               'id' => StringUtility::getUniqueId('select_checkbox_row_'),
                                                'name' => $parameterArray['itemFormElName'] . '[' . $c . ']',
                                                'value' => $p[1],
                                                'checked' => $checked,
@@ -165,7 +165,7 @@ class SelectCheckBoxElement extends AbstractFormElement {
                        foreach ($itemArray as $theNoMatchValue => $temp) {
                                // Build item array
                                $groups[$currentGroup]['items'][] = array(
-                                       'id' => str_replace('.', '', uniqid('select_checkbox_row_', TRUE)),
+                                       'id' => StringUtility::getUniqueId('select_checkbox_row_'),
                                        'name' => $parameterArray['itemFormElName'] . '[' . $c . ']',
                                        'value' => $theNoMatchValue,
                                        'checked' => 1,
index b2aeda7..695b893 100644 (file)
@@ -14,9 +14,9 @@ namespace TYPO3\CMS\Backend\Form\Element;
  * The TYPO3 project - inspiring people to share!
  */
 
-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\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
@@ -161,7 +161,7 @@ class SelectMultipleSideBySideElement extends AbstractFormElement {
                                : '';
                        $sOnChange = implode('', $parameterArray['fieldChangeFunc']);
 
-                       $multiSelectId = str_replace('.', '', uniqid('tceforms-multiselect-', TRUE));
+                       $multiSelectId = StringUtility::getUniqueId('tceforms-multiselect-');
                        $itemsToSelect = '
                                <select data-relatedfieldname="' . htmlspecialchars($parameterArray['itemFormElName']) . '" data-exclusivevalues="'
                                . htmlspecialchars($config['exclusiveKeys']) . '" id="' . $multiSelectId . '" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '_sel" '
index 543e338..ef6f670 100644 (file)
@@ -17,7 +17,7 @@ namespace TYPO3\CMS\Backend\Form\Element;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
 
@@ -137,7 +137,7 @@ class SelectSingleBoxElement extends AbstractFormElement {
                $size = $config['autoSizeMax']
                        ? MathUtility::forceIntegerInRange(count($selItems) + 1, MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax'])
                        : $size;
-               $selectBox = '<select id="' . str_replace('.', '', uniqid($cssPrefix, TRUE)) . '" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '[]" '
+               $selectBox = '<select id="' . StringUtility::getUniqueId($cssPrefix) . '" name="' . htmlspecialchars($parameterArray['itemFormElName']) . '[]" '
                        . 'class="form-control ' . $cssPrefix . '"' . ($size ? ' size="' . $size . '" ' : '')
                        . ' multiple="multiple" onchange="' . htmlspecialchars($sOnChange) . '"' . $parameterArray['onFocus']
                        . ' ' . $this->getValidationDataAsDataAttribute($config) . $selector_itemListStyle . $disabled . '>
index d8c13e6..64ff57e 100644 (file)
@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Backend\Form\Element;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
 use TYPO3\CMS\Backend\Form\InlineStackProcessor;
@@ -110,7 +110,7 @@ class SelectSingleElement extends AbstractFormElement {
                }
 
                // Initialization:
-               $selectId = str_replace('.', '', uniqid('tceforms-select-', TRUE));
+               $selectId = StringUtility::getUniqueId('tceforms-select-');
                $selectedIndex = 0;
                $selectedIcon = '';
                $selectedValueFound = FALSE;
index ed09941..321abb8 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Form\Element;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 
 /**
@@ -139,7 +140,7 @@ class TextElement extends AbstractFormElement {
                        }
 
                        // calculate attributes
-                       $attributes['id'] = str_replace('.', '', uniqid('formengine-textarea-', TRUE));
+                       $attributes['id'] = StringUtility::getUniqueId('formengine-textarea-');
                        $attributes['name'] = $parameterArray['itemFormElName'];
                        if (!empty($styles)) {
                                $attributes['style'] = implode(' ', $styles);
index b7589a5..be2fdb5 100644 (file)
@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Backend\Form\FormDataProvider;
  */
 
 use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * On "new" command, initialize uid with an unqique uid
@@ -40,10 +40,8 @@ class DatabaseUniqueUidNewRow implements FormDataProviderInterface {
                                1437991120
                        );
                }
-               // @todo: There is a dot in this uid that can give us headaches if the
-               // @todo: uid is used as id argument in HTML. It would probably better
-               // @todo: to remove the dot here already.
-               $result['databaseRow']['uid'] = uniqid('NEW', TRUE);
+               $result['databaseRow']['uid'] = StringUtility::getUniqueId('NEW');
+
                return $result;
        }
 
index caabc93..38eba68 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 
@@ -122,7 +123,7 @@ class InlineRelatedRecordResolver {
                                        if (!empty($foreignTranslationPointerField)) {
                                                $record[$foreignTranslationPointerField] = $record['uid'];
                                        }
-                                       $newId = uniqid('NEW', TRUE);
+                                       $newId = StringUtility::getUniqueId('NEW');
                                        $record['uid'] = $newId;
                                        $record['pid'] = $inlineFirstPid;
                                        $relatedRecords['records'][$newId] = $record;
@@ -141,7 +142,7 @@ class InlineRelatedRecordResolver {
         */
        public function getNewRecord($pid, $table) {
                $record = $this->getRecord($table, $pid, 'new');
-               $record['uid'] = uniqid('NEW', TRUE);
+               $record['uid'] = StringUtility::getUniqueId('NEW');
                $newRecordPid = $pid;
                $pageTS = BackendUtility::getPagesTSconfig($pid);
                // @todo: this is to force new foreign records to a different pid via pageTS - should be handled elsewhere
index c06ca3d..80f4554 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 use TYPO3\CMS\Extbase\Service\FlexFormService;
 use TYPO3\CMS\Fluid\View\StandaloneView;
@@ -484,8 +485,8 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                                . $this->getLanguageService()->getLL('content', TRUE) . '</a>';
                                }
                                $content[$key] .= '
-                               <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . str_replace('.', '', uniqid('', TRUE)) . '">
-                                       <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . uniqid('', TRUE) . '">'
+                               <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . StringUtility::getUniqueId() . '">
+                                       <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id . '-' . StringUtility::getUniqueId() . '">'
                                                . $link
                                        . '</div>
                                        <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
@@ -515,7 +516,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                                $editUidList .= $row['uid'] . ',';
                                                $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0;
                                                if (!$this->tt_contentConfig['languageMode']) {
-                                                       $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . str_replace('.', '', uniqid('', TRUE)) . '">';
+                                                       $singleElementHTML .= '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
                                                }
                                                $singleElementHTML .= $this->tt_content_drawHeader(
                                                        $row,
@@ -538,7 +539,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                                        $singleElementHTML .= '<div class="t3-page-ce t3js-page-ce">';
                                                }
                                                $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $key . '-' . 'page-' . $id .
-                                                       '-' . str_replace('.', '', uniqid('', TRUE)) . '">';
+                                                       '-' . StringUtility::getUniqueId() . '">';
                                                // Add icon "new content element below"
                                                if (!$disableMoveAndNewButtons && $this->getPageLayoutController()->pageIsNotLockedForEditors()) {
                                                        // New content element:
index fec505d..df571d9 100644 (file)
@@ -13,7 +13,9 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 
 /**
@@ -146,7 +148,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
                        throw new \RuntimeException(sprintf('Cannot add or modify cache entry because the backend of cache "%s" is frozen.', $this->cacheIdentifier), 1323344192);
                }
                $this->remove($entryIdentifier);
-               $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . uniqid('', TRUE) . '.temp';
+               $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . StringUtility::getUniqueId() . '.temp';
                $lifetime = $lifetime === NULL ? $this->defaultLifetime : $lifetime;
                $expiryTime = $lifetime === 0 ? 0 : $GLOBALS['EXEC_TIME'] + $lifetime;
                $metaData = str_pad($expiryTime, self::EXPIRYTIME_LENGTH) . implode(' ', $tags) . str_pad(strlen($data), self::DATASIZE_DIGITS);
index ad4dca6..44513d1 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\StringUtility;
+
 /**
  * A caching backend which stores cache entries by using Redis with phpredis
  * PHP module. Redis is a noSQL database with very good scaling characteristics
@@ -474,7 +476,7 @@ class RedisBackend extends AbstractBackend implements TaggableBackendInterface {
        protected function removeIdentifierEntriesAndRelations(array $identifiers, array $tags) {
                // Set a temporary entry which holds all identifiers that need to be removed from
                // the tag to identifiers sets
-               $uniqueTempKey = 'temp:' . uniqid('', TRUE);
+               $uniqueTempKey = 'temp:' . StringUtility::getUniqueId();
                $prefixedKeysToDelete = array($uniqueTempKey);
                $prefixedIdentifierToTagsKeysToDelete = array();
                foreach ($identifiers as $identifier) {
index cd8236e..e0b8ec3 100644 (file)
@@ -10,8 +10,10 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * A caching backend which stores cache entries in files, but does not support or
@@ -237,7 +239,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
                if ($entryIdentifier === '') {
                        throw new \InvalidArgumentException('The specified entry identifier must not be empty.', 1334756736);
                }
-               $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . uniqid('', TRUE) . '.temp';
+               $temporaryCacheEntryPathAndFilename = $this->cacheDirectory . StringUtility::getUniqueId() . '.temp';
                $result = file_put_contents($temporaryCacheEntryPathAndFilename, $data);
                \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($temporaryCacheEntryPathAndFilename);
                if ($result === FALSE) {
index fa4b1bd..909ca96 100644 (file)
@@ -32,6 +32,7 @@ use TYPO3\CMS\Core\Utility\File\BasicFileUtility;
 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\Core\Versioning\VersionState;
 
 /**
@@ -3375,7 +3376,7 @@ class DataHandler {
                }
 
                // Initializing:
-               $theNewID = uniqid('NEW', TRUE);
+               $theNewID = StringUtility::getUniqueId('NEW');
                $enableField = isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) ? $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'] : '';
                $headerField = $GLOBALS['TCA'][$table]['ctrl']['label'];
                // Getting default data:
@@ -3628,7 +3629,7 @@ class DataHandler {
         * @return int Returns the new ID of the record (if applicable)
         */
        public function insertNewCopyVersion($table, $fieldArray, $realPid) {
-               $id = uniqid('NEW', TRUE);
+               $id = StringUtility::getUniqueId('NEW');
                // $fieldArray is set as current record.
                // The point is that when new records are created as copies with flex type fields there might be a field containing information about which DataStructure to use and without that information the flexforms cannot be correctly processed.... This should be OK since the $checkValueRecord is used by the flexform evaluation only anyways...
                $this->checkValue_currentRecord = $fieldArray;
index 5ccb39d..6c6c2bf 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Database;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Contains the class "DatabaseConnection" containing functions for building SQL queries
@@ -334,7 +335,7 @@ class DatabaseConnection {
         * @see exec_SELECTquery()
         */
        public function exec_SELECT_mm_query($select, $local_table, $mm_table, $foreign_table, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '') {
-               $foreign_table_as = $foreign_table == $local_table ? $foreign_table . str_replace('.', '', uniqid('_join', TRUE)) : '';
+               $foreign_table_as = $foreign_table == $local_table ? $foreign_table . StringUtility::getUniqueId('_join') : '';
                $mmWhere = $local_table ? $local_table . '.uid=' . $mm_table . '.uid_local' : '';
                $mmWhere .= ($local_table and $foreign_table) ? ' AND ' : '';
                $tables = ($local_table ? $local_table . ',' : '') . $mm_table;
index e1c6f0f..74d21cb 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Module\BaseScriptClass;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Lang\LanguageService;
 
 /**
@@ -1604,7 +1605,7 @@ class QueryGenerator {
        protected function getDateTimePickerField($name, $timestamp, $type) {
                $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? '%H:%M %m-%d-%Y' : '%H:%M %d-%m-%Y';
                $value = ($timestamp > 0 ? strftime($dateFormat, $timestamp) : '');
-               $id = uniqid('dt_');
+               $id = StringUtility::getUniqueId('dt_');
                $html = array();
                $html[] = '<div class="input-group" id="' . $id . '-wrapper">';
                $html[] = '             <input name="' . htmlspecialchars($name) . '_hr" value="' . $value . '" class="form-control t3js-datetimepicker t3js-clearable" data-date-type="' . htmlspecialchars($type) . '" data-date-offset="0" type="text" id="' . $id . '">';
index 11b1b96..8dfb4cb 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Core\ClassLoadingInformation;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * The default TYPO3 Package Manager
@@ -189,7 +190,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface {
                $cacheEntryIdentifier = $this->getCacheEntryIdentifier();
                if ($cacheEntryIdentifier !== NULL && !$this->coreCache->has($cacheEntryIdentifier)) {
                        // Package objects get their own cache entry, so PHP does not have to parse the serialized string
-                       $packageObjectsCacheEntryIdentifier = str_replace('.', '', uniqid('PackageObjects_', TRUE));
+                       $packageObjectsCacheEntryIdentifier = StringUtility::getUniqueId('PackageObjects_');
                        // Build cache file
                        $packageCache = array(
                                'packageStatesConfiguration'  => $this->packageStatesConfiguration,
index 9cce429..eda5b7f 100755 (executable)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Core\ClassLoadingInformation;
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\SingletonInterface;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
@@ -1232,7 +1233,7 @@ class GeneralUtility {
        static protected function generateRandomBytesFallback($bytesToReturn) {
                $bytes = '';
                // We initialize with somewhat random.
-               $randomState = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . base_convert(memory_get_usage() % pow(10, 6), 10, 2) . microtime() . uniqid('', TRUE) . getmypid();
+               $randomState = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . base_convert(memory_get_usage() % pow(10, 6), 10, 2) . microtime() . StringUtility::getUniqueId() . getmypid();
                while (!isset($bytes[($bytesToReturn - 1)])) {
                        $randomState = sha1(microtime() . mt_rand() . $randomState);
                        $bytes .= sha1(mt_rand() . $randomState, TRUE);
@@ -2822,7 +2823,7 @@ Connection: close
                $result = FALSE;
 
                if (is_dir($directory)) {
-                       $temporaryDirectory = rtrim($directory, '/') . '.' . uniqid('remove', TRUE) . '/';
+                       $temporaryDirectory = rtrim($directory, '/') . '.' . StringUtility::getUniqueId('remove') . '/';
                        if (rename($directory, $temporaryDirectory)) {
                                if ($flushOpcodeCache) {
                                        GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive($directory);
index 5bd30ca..5252eb9 100644 (file)
@@ -110,4 +110,16 @@ class StringUtility {
                return $position !== FALSE && $position === $haystackLength - $needleLength;
        }
 
+       /**
+        * This function generates a unique id by using the more entropy parameter.
+        * Furthermore the dots are removed so the id can be used inside HTML attributes e.g. id.
+        *
+        * @param string $prefix
+        * @return string
+        */
+       static public function getUniqueId($prefix = '') {
+               $uniqueId = uniqid($prefix, TRUE);
+               return str_replace('.', '', $uniqueId);
+       }
+
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-69730-IntroduceUniqueIdGenerator.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-69730-IntroduceUniqueIdGenerator.rst
new file mode 100644 (file)
index 0000000..89bd7f3
--- /dev/null
@@ -0,0 +1,21 @@
+==============================================
+Feature: #69730 - Introduce uniqueId generator
+==============================================
+
+Description
+===========
+
+A new method ``getUniqueId()`` has been added to the StringUtility class.
+Now there is a common way to generate an unique identifier which can be
+used even in HTML tag attributes as it removes the invalid dot character.
+
+
+.. code-block:: php
+
+       $uniqueId = \TYPO3\CMS\Core\Utility\StringUtility::getUniqueId('Prefix');
+
+
+Impact
+======
+
+No need to remove the dot manually anymore.
index 0516131..e9631c9 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Tests;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\StringUtility;
+
 /**
  * The mother of all test cases.
  *
@@ -114,7 +116,7 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase {
         * @return string Fully qualified name of the built class, will not be empty
         */
        protected function buildAccessibleProxy($className) {
-               $accessibleClassName = str_replace('.', '', $this->getUniqueId('Tx_Phpunit_AccessibleProxy'));
+               $accessibleClassName = $this->getUniqueId('Tx_Phpunit_AccessibleProxy');
                $class = new \ReflectionClass($className);
                $abstractModifier = $class->isAbstract() ? 'abstract ' : '';
 
@@ -277,7 +279,7 @@ abstract class BaseTestCase extends \PHPUnit_Framework_TestCase {
         * @return string
         */
        protected function getUniqueId($prefix = '') {
-               return $prefix . str_replace('.', '', uniqid(mt_rand(), TRUE));
+               return $prefix . StringUtility::getUniqueId(mt_rand());
        }
 
 }
index 877f582..5d32b25 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\DataHandling\Framework;
  */
 
 use TYPO3\CMS\Core\DataHandling\DataHandler;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * DataHandler Actions
@@ -59,7 +60,7 @@ class ActionService {
                        if (!isset($recordData['pid'])) {
                                $recordData['pid'] = $pageId;
                        }
-                       $currentUid = uniqid('NEW', TRUE);
+                       $currentUid = StringUtility::getUniqueId('NEW');
                        $newTableIds[$tableName][] = $currentUid;
                        $dataMap[$tableName][$currentUid] = $recordData;
                        if ($previousTableName !== NULL && $previousUid !== NULL) {
@@ -131,7 +132,7 @@ class ActionService {
                        $currentUid = $recordData['uid'];
                        if ($recordData['uid'] === '__NEW') {
                                $recordData['pid'] = $pageId;
-                               $currentUid = uniqid('NEW', TRUE);
+                               $currentUid = StringUtility::getUniqueId('NEW');
                        }
                        unset($recordData['uid']);
                        $dataMap[$tableName][$currentUid] = $recordData;
index e1d4416..5c9c666 100644 (file)
@@ -259,4 +259,19 @@ class StringUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                StringUtility::beginsWith($string, $part);
        }
 
+       /**
+        * @test
+        */
+       public function getUniqueIdReturnsIdWithPrefix() {
+               $id = StringUtility::getUniqueId('NEW');
+               $this->assertEquals('NEW', substr($id, 0, 3));
+       }
+
+       /**
+        * @test
+        */
+       public function getUniqueIdReturnsIdWithoutDot() {
+               $this->assertNotContains('.', StringUtility::getUniqueId());
+       }
+
 }
index 7235616..d04085c 100644 (file)
@@ -1,14 +1,6 @@
 <?php
 namespace typo3\sysext\form\Tests\Unit\Domain;
 
-use TYPO3\CMS\Core\Tests\UnitTestCase;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Form\Domain\Model\Attribute\AbstractAttribute;
-use TYPO3\CMS\Form\Domain\Model\Attribute\AttributesAttribute;
-use TYPO3\CMS\Form\Localization;
-use TYPO3\CMS\Form\Request;
-use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
-
 /*
  * This file is part of the TYPO3 CMS project.
  *
@@ -22,6 +14,15 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Tests\UnitTestCase;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
+use TYPO3\CMS\Form\Domain\Model\Attribute\AbstractAttribute;
+use TYPO3\CMS\Form\Domain\Model\Attribute\AttributesAttribute;
+use TYPO3\CMS\Form\Localization;
+use TYPO3\CMS\Form\Request;
+use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+
 /**
  * Test case for class \TYPO3\CMS\Form\Domain\Model\Attribute\AttributesAttribute
  */
@@ -53,7 +54,7 @@ class AttributesAttributeTest extends UnitTestCase {
                $requestProphecy = $this->prophesize(Request::class);
                $this->singletonInstances = GeneralUtility::getSingletonInstances();
                GeneralUtility::setSingletonInstance(Request::class, $requestProphecy->reveal());
-               $this->elementId = uniqid('elementId_', TRUE);
+               $this->elementId = StringUtility::getUniqueId('elementId_');
                $this->subject = new AttributesAttribute($this->elementId);
        }
 
index 2bff1e2..110b4d9 100644 (file)
@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * EXAMPLE for using the impexp-class for exporting stuff:
@@ -2107,11 +2108,11 @@ class ImportExport {
                                        $this->import_mapId['sys_file_metadata'][$record['uid']] = $recordInDatabase['uid'];
                                        $ID = $recordInDatabase['uid'];
                                } else {
-                                       $ID = uniqid('NEW', TRUE);
+                                       $ID = StringUtility::getUniqueId('NEW');
                                }
 
                        } else {
-                               $ID = uniqid('NEW', TRUE);
+                               $ID = StringUtility::getUniqueId('NEW');
                        }
                        $this->import_newId[$table . ':' . $ID] = array('table' => $table, 'uid' => $uid);
                        if ($table == 'pages') {
@@ -2315,7 +2316,7 @@ class ImportExport {
                                                                                                }
                                                                                        }
                                                                                        if ($fileObject !== NULL) {
-                                                                                               $refId = uniqid('NEW', TRUE);
+                                                                                               $refId = StringUtility::getUniqueId('NEW');
                                                                                                $refIds[] = $refId;
                                                                                                $updateData['sys_file_reference'][$refId] = array(
                                                                                                        'uid_local' => $fileObject->getUid(),
index f6f7a48..5572daf 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\Controller\Action\Tool;
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 use TYPO3\CMS\Install\Controller\Action;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Test various system setup settings
@@ -187,7 +188,7 @@ class TestSetup extends Action\AbstractAction {
                        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('install') . 'Resources/Private/Font/vera.ttf',
                        'Testing true type'
                );
-               $outputFile = PATH_site . 'typo3temp/installTool-' . uniqid('createTrueTypeFontTestImage', TRUE) . '.gif';
+               $outputFile = PATH_site . 'typo3temp/installTool-' . StringUtility::getUniqueId('createTrueTypeFontTestImage') . '.gif';
                imagegif($image, $outputFile);
 
                /** @var \TYPO3\CMS\Install\Status\StatusInterface $message */
@@ -232,7 +233,7 @@ class TestSetup extends Action\AbstractAction {
                        } else {
                                $imageProcessor->IM_commands = array();
                                $inputFile = $this->imageBasePath . 'TestInput/Test.' . $formatToTest;
-                               $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid('read', TRUE) . '-' . $formatToTest;
+                               $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('read') . '-' . $formatToTest;
                                $imResult = $imageProcessor->imageMagickConvert($inputFile, 'jpg', '170', '', '', '', array(), TRUE);
                                $result['title'] = 'Read ' . $formatToTest;
                                if ($imResult !== NULL) {
@@ -268,7 +269,7 @@ class TestSetup extends Action\AbstractAction {
 
                // Gif
                $inputFile = $this->imageBasePath . 'TestInput/Test.gif';
-               $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid('write-gif', TRUE);
+               $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('write-gif');
                $imResult = $imageProcessor->imageMagickConvert($inputFile, 'gif', '', '', '', '', array(), TRUE);
                if ($imResult !== NULL && is_file($imResult[3])) {
                        if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gif_compress']) {
@@ -301,7 +302,7 @@ class TestSetup extends Action\AbstractAction {
                // Png
                $inputFile = $this->imageBasePath . 'TestInput/Test.png';
                $imageProcessor->IM_commands = array();
-               $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid('write-png', TRUE);
+               $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('write-png');
                $imResult = $imageProcessor->imageMagickConvert($inputFile, 'png', '', '', '', '', array(), TRUE);
                if ($imResult !== NULL) {
                        $testResults['png']['title'] = 'Write png';
@@ -334,7 +335,7 @@ class TestSetup extends Action\AbstractAction {
 
                $imageProcessor->IM_commands = array();
                $inputFile = $this->imageBasePath . 'TestInput/Transparent.gif';
-               $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid('scale-gif', TRUE);
+               $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('scale-gif');
                $imResult = $imageProcessor->imageMagickConvert($inputFile, 'gif', '150', '', '', '', array(), TRUE);
                if ($imResult !== NULL) {
                        $testResults['gif-to-gif']['title'] = 'gif to gif';
@@ -347,7 +348,7 @@ class TestSetup extends Action\AbstractAction {
 
                $imageProcessor->IM_commands = array();
                $inputFile = $this->imageBasePath . 'TestInput/Transparent.png';
-               $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid('scale-png', TRUE);
+               $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('scale-png');
                $imResult = $imageProcessor->imageMagickConvert($inputFile, 'png', '150', '', '', '', array(), TRUE);
                if ($imResult !== NULL) {
                        $testResults['png-to-png']['title'] = 'png to png';
@@ -360,7 +361,7 @@ class TestSetup extends Action\AbstractAction {
 
                $imageProcessor->IM_commands = array();
                $inputFile = $this->imageBasePath . 'TestInput/Transparent.gif';
-               $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid('scale-jpg', TRUE);
+               $imageProcessor->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId('scale-jpg');
                $imResult = $imageProcessor->imageMagickConvert($inputFile, 'jpg', '150', '', '-opaque white -background white -flatten', '', array(), TRUE);
                if ($imResult !== NULL) {
                        $testResults['gif-to-jpg']['title'] = 'gif to jpg';
@@ -394,7 +395,7 @@ class TestSetup extends Action\AbstractAction {
                $overlayFile = $this->imageBasePath . 'TestInput/Test.jpg';
                $maskFile = $this->imageBasePath . 'TestInput/MaskBlackWhite.gif';
                $resultFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix
-                       . uniqid($imageProcessor->alternativeOutputKey . 'combine1', TRUE) . '.jpg';
+                       . StringUtility::getUniqueId($imageProcessor->alternativeOutputKey . 'combine1') . '.jpg';
                $imageProcessor->combineExec($inputFile, $overlayFile, $maskFile, $resultFile, TRUE);
                $result = $imageProcessor->getImageDimensions($resultFile);
                if ($result) {
@@ -411,7 +412,7 @@ class TestSetup extends Action\AbstractAction {
                $overlayFile = $this->imageBasePath . 'TestInput/Test.jpg';
                $maskFile = $this->imageBasePath . 'TestInput/MaskCombine.jpg';
                $resultFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix
-                       . uniqid($imageProcessor->alternativeOutputKey . 'combine2', TRUE) . '.jpg';
+                       . StringUtility::getUniqueId($imageProcessor->alternativeOutputKey . 'combine2') . '.jpg';
                $imageProcessor->combineExec($inputFile, $overlayFile, $maskFile, $resultFile, TRUE);
                $result = $imageProcessor->getImageDimensions($resultFile);
                if ($result) {
@@ -450,7 +451,7 @@ class TestSetup extends Action\AbstractAction {
                        'color' => 'olive',
                );
                $imageProcessor->makeBox($image, $conf, $workArea);
-               $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid('gdSimple', TRUE) . '.' . $gifOrPng;
+               $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdSimple') . '.' . $gifOrPng;
                $imageProcessor->ImageWrite($image, $outputFile);
                $result = $imageProcessor->getImageDimensions($outputFile);
                $testResults['simple'] = array();
@@ -468,7 +469,7 @@ class TestSetup extends Action\AbstractAction {
                        'color' => 'olive',
                );
                $imageProcessor->makeBox($image, $conf, $workArea);
-               $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid('gdBox', TRUE) . '.' . $gifOrPng;
+               $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdBox') . '.' . $gifOrPng;
                $imageProcessor->ImageWrite($image, $outputFile);
                $result = $imageProcessor->getImageDimensions($outputFile);
                $testResults['box'] = array();
@@ -494,7 +495,7 @@ class TestSetup extends Action\AbstractAction {
                );
                $conf['BBOX'] = $imageProcessor->calcBBox($conf);
                $imageProcessor->makeText($image, $conf, $workArea);
-               $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid('gdText', TRUE) . '.' . $gifOrPng;
+               $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdText') . '.' . $gifOrPng;
                $imageProcessor->ImageWrite($image, $outputFile);
                $result = $imageProcessor->getImageDimensions($outputFile);
                $testResults['text'] = array();
@@ -509,7 +510,7 @@ class TestSetup extends Action\AbstractAction {
                        $conf['offset'] = '17,65';
                        $conf['niceText'] = 1;
                        $imageProcessor->makeText($image, $conf, $workArea);
-                       $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid('gdNiceText', TRUE) . '.' . $gifOrPng;
+                       $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('gdNiceText') . '.' . $gifOrPng;
                        $imageProcessor->ImageWrite($image, $outputFile);
                        $result = $imageProcessor->getImageDimensions($outputFile);
                        $testResults['niceText']['title'] = 'Render text with TrueType font using \'niceText\' option';
@@ -545,7 +546,7 @@ class TestSetup extends Action\AbstractAction {
                        // Warning: Re-uses $image from above!
                        $imageProcessor->makeShadow($image, $conf['shadow.'], $workArea, $conf);
                        $imageProcessor->makeText($image, $conf, $workArea);
-                       $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid('GDwithText-niceText-shadow', TRUE) . '.' . $gifOrPng;
+                       $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . StringUtility::getUniqueId('GDwithText-niceText-shadow') . '.' . $gifOrPng;
                        $imageProcessor->ImageWrite($image, $outputFile);
                        $result = $imageProcessor->getImageDimensions($outputFile);
                        $testResults['shadow']['title'] = 'Render \'niceText\' with a shadow under';
index a1c1466..f3bd631 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\FolderStructure;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Install\Status;
 
 /**
@@ -243,7 +244,7 @@ class DirectoryNode extends AbstractNode implements NodeInterface {
         * @return bool TRUE if test file creation was successful
         */
        protected function canFileBeCreated() {
-               $testFileName = uniqid('installToolTest_', TRUE);
+               $testFileName = StringUtility::getUniqueId('installToolTest_');
                $result = @touch($this->getAbsolutePath() . '/' . $testFileName);
                if ($result === TRUE) {
                        unlink($this->getAbsolutePath() . '/' . $testFileName);
index 24b4871..140355b 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Service\OpcodeCacheService;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Install\FolderStructure\DefaultFactory;
 use TYPO3\CMS\Install\Service\Exception\RemoteFetchException;
 use TYPO3\CMS\Install\Status\ErrorStatus;
@@ -205,7 +206,7 @@ class CoreUpdateService {
 
                if ($success) {
                        // Explicit write check to document root
-                       $file = PATH_site . uniqid('install-core-update-test-', TRUE);
+                       $file = PATH_site . StringUtility::getUniqueId('install-core-update-test-');
                        $result = @touch($file);
                        if (!$result) {
                                $success = FALSE;
@@ -221,7 +222,7 @@ class CoreUpdateService {
                        if (!$this->checkCoreFilesAvailable($version)) {
                                // Explicit write check to upper directory of current core location
                                $coreLocation = @realPath($this->symlinkToCoreFiles . '/../');
-                               $file = $coreLocation . '/' . uniqid('install-core-update-test-', TRUE);
+                               $file = $coreLocation . '/' . StringUtility::getUniqueId('install-core-update-test-');
                                $result = @touch($file);
                                if (!$result) {
                                        $success = FALSE;
index 4859c38..a369810 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Mediace\ContentObject;
 
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Contains FlowPlayer class object.
@@ -211,7 +212,7 @@ class FlowPlayerContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstract
                        $prefix = $GLOBALS['TSFE']->absRefPrefix;
                }
                // Initialize content
-               $replaceElementIdString = str_replace('.', '', uniqid('mmswf', TRUE));
+               $replaceElementIdString = StringUtility::getUniqueId('mmswf');
                $GLOBALS['TSFE']->register['MMSWFID'] = $replaceElementIdString;
                $layout = isset($conf['layout.']) ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) : $conf['layout'];
                $content = str_replace('###ID###', $replaceElementIdString, $layout);
index 40c8d3b..7c723c9 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Mediace\ContentObject;
  */
 
 use TYPO3\CMS\Core\Utility\ArrayUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Contains QTOBJECT content object.
@@ -49,7 +50,7 @@ class QuicktimeObjectContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abs
                $typeConf = $conf[$type . '.'];
                // Add QTobject js-file
                $this->getPageRenderer()->addJsFile($this->getPathToLibrary('flashmedia/qtobject/qtobject.js'));
-               $replaceElementIdString = str_replace('.', '', uniqid('mmqt', TRUE));
+               $replaceElementIdString = StringUtility::getUniqueId('mmqt');
                $GLOBALS['TSFE']->register['MMQTID'] = $replaceElementIdString;
                $qtObject = 'QTObject' . $replaceElementIdString;
                // Merge with default parameters
index 7d308ca..a56a21e 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Mediace\ContentObject;
  */
 
 use TYPO3\CMS\Core\Utility\ArrayUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Contains SWFOBJECT content object.
@@ -100,7 +101,7 @@ class ShockwaveFlashObjectContentObject extends \TYPO3\CMS\Frontend\ContentObjec
                if (!$flashVersion) {
                        $flashVersion = '9';
                }
-               $replaceElementIdString = str_replace('.', '', uniqid('mmswf', TRUE));
+               $replaceElementIdString = StringUtility::getUniqueId('mmswf');
                $GLOBALS['TSFE']->register['MMSWFID'] = $replaceElementIdString;
                $alternativeContent = isset($conf['alternativeContent.']) ? $this->cObj->stdWrap($conf['alternativeContent'], $conf['alternativeContent.']) : $conf['alternativeContent'];
                $layout = isset($conf['layout.']) ? $this->cObj->stdWrap($conf['layout'], $conf['layout.']) : $conf['layout'];
index e4d8a36..51c1f72 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Rsaauth\Backend;
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\CommandUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * This class contains an OpenSSL backend for the TYPO3 RSA authentication
@@ -84,7 +85,7 @@ class CommandLineBackend extends AbstractBackend {
                }
 
                // Create a temporary file. Security: tempnam() sets permissions to 0600
-               $privateKeyFile = tempnam($this->temporaryDirectory, uniqid('', TRUE));
+               $privateKeyFile = tempnam($this->temporaryDirectory, StringUtility::getUniqueId());
 
                // Generate the private key.
                //
@@ -127,9 +128,9 @@ class CommandLineBackend extends AbstractBackend {
         */
        public function decrypt($privateKey, $data) {
                // Key must be put to the file
-               $privateKeyFile = tempnam($this->temporaryDirectory, uniqid('', TRUE));
+               $privateKeyFile = tempnam($this->temporaryDirectory, StringUtility::getUniqueId());
                file_put_contents($privateKeyFile, $privateKey);
-               $dataFile = tempnam($this->temporaryDirectory, uniqid('', TRUE));
+               $dataFile = tempnam($this->temporaryDirectory, StringUtility::getUniqueId());
                file_put_contents($dataFile, base64_decode($data));
                // Prepare the command
                $command = $this->opensslPath . ' rsautl -inkey ' . escapeshellarg($privateKeyFile) . ' -in ' . escapeshellarg($dataFile) . ' -decrypt';
index bdc4a2b..add7257 100644 (file)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 
 /**
  * Generation of form element of the type rsaInput
@@ -107,7 +108,7 @@ class RsaInputElement extends AbstractFormElement {
                // calculate attributes
                $attributes['data-formengine-validation-rules'] = $this->getValidationDataAsJsonString($config);
                $attributes['data-formengine-input-params'] = json_encode($paramsList);
-               $attributes['id'] = str_replace('.', '', uniqid('formengine-input-', TRUE));
+               $attributes['id'] = StringUtility::getUniqueId('formengine-input-');
                $attributes['name'] = $parameterArray['itemFormElName'] . '_hr';
                if (isset($config['max']) && (int)$config['max'] > 0) {
                        $attributes['maxlength'] = (int)$config['max'];
index fa205f7..c78fdae 100644 (file)
@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Scheduler\Controller;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
@@ -25,6 +24,7 @@ use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
+use TYPO3\CMS\Core\Utility\StringUtility;
 use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;
 use TYPO3\CMS\Saltedpasswords\Salt\SaltFactory;
 use TYPO3\CMS\Saltedpasswords\Utility\SaltedPasswordsUtility;
@@ -312,7 +312,7 @@ class SchedulerModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClas
                // If the user does not exist, try creating it
                if ($checkUser == -1) {
                        // Prepare necessary data for _cli_scheduler user creation
-                       $password = uniqid('scheduler', TRUE);
+                       $password = StringUtility::getUniqueId('scheduler');
                        if (SaltedPasswordsUtility::isUsageEnabled()) {
                                $objInstanceSaltedPW = SaltFactory::getSaltingInstance();
                                $password = $objInstanceSaltedPW->getHashedPassword($password);