[TASK] Fix CGL issues
authorxperseguers <xperseguers@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 8 Sep 2011 09:33:34 +0000 (09:33 +0000)
committerxperseguers <xperseguers@735d13b6-9817-0410-8766-e36946ffe9aa>
Thu, 8 Sep 2011 09:33:34 +0000 (09:33 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/identity/trunk@51745 735d13b6-9817-0410-8766-e36946ffe9aa

Classes/Hooks/class.tx_identity_tcemain_hook.php
Classes/Install/Installer.php
Classes/Provider/AbstractUuid.php
Classes/Utility/Algorithms.php
Classes/Utility/FieldDefinitions.php
class.ext_update.php
ext_emconf.php
ext_localconf.php
ext_tables.php

index 90c0ff0..129ac76 100644 (file)
@@ -2,6 +2,7 @@
 
 class tx_identity_tcemain_hook {
        public function processDatamap_afterAllOperations($parent) {
+               /** @var $identityMap Tx_Identity_Map */
                $identityMap = t3lib_div::makeInstance('Tx_Identity_Map');
                // $identityMap->rebuild();
                $identityMap->commit();
index 82860ef..6c2d8c0 100644 (file)
@@ -73,7 +73,7 @@ class Tx_Identity_Install_Installer implements t3lib_Singleton {
                                $statementArray[$statementArrayPointer] .= $lineContent;
                                $is_set = 1;
                        }
-                       if (substr(trim($lineContent), -1) == ';') {
+                       if (substr(trim($lineContent), -1) === ';') {
                                if (isset($statementArray[$statementArrayPointer])) {
                                        if (!trim($statementArray[$statementArrayPointer]) || ($query_regex && !preg_match('/' . $query_regex . '/i', trim($statementArray[$statementArrayPointer])))) {
                                                unset($statementArray[$statementArrayPointer]);
@@ -108,7 +108,7 @@ class Tx_Identity_Install_Installer implements t3lib_Singleton {
                $total = array();
 
                foreach ($lines as $value) {
-                       if (substr($value, 0, 1) == '#') {
+                       if (substr($value, 0, 1) === '#') {
                                continue; // Ignore comments
                        }
 
@@ -116,12 +116,12 @@ class Tx_Identity_Install_Installer implements t3lib_Singleton {
                                $parts = t3lib_div::trimExplode(' ', $value, TRUE);
                                if (strtoupper($parts[0]) === 'CREATE' && strtoupper($parts[1]) === 'TABLE') {
                                        $table = str_replace('`', '', $parts[2]);
-                                       if (TYPO3_OS == 'WIN') { // tablenames are always lowercase on windows!
+                                       if (TYPO3_OS === 'WIN') { // tablenames are always lowercase on windows!
                                                $table = strtolower($table);
                                        }
                                }
                        } else {
-                               if (substr($value, 0, 1) == ')' && substr($value, -1) == ';') {
+                               if (substr($value, 0, 1) === ')' && substr($value, -1) === ';') {
                                        $ttype = array();
                                        if (preg_match('/(ENGINE|TYPE)[ ]*=[ ]*([a-zA-Z]*)/', $value, $ttype)) {
                                                $total[$table]['extra']['ENGINE'] = $ttype[2];
@@ -420,7 +420,7 @@ class Tx_Identity_Install_Installer implements t3lib_Singleton {
                                                        if (is_array($info[$theKey])) {
                                                                foreach ($info[$theKey] as $fieldN => $fieldC) {
                                                                        $fieldN = str_replace('`', '', $fieldN);
-                                                                       if ($fieldN == 'COLLATE') {
+                                                                       if ($fieldN === 'COLLATE') {
                                                                                continue; // TODO: collation support is currently disabled (needs more testing)
                                                                        }
 
@@ -492,7 +492,7 @@ class Tx_Identity_Install_Installer implements t3lib_Singleton {
                                                                                $info['extra']['CLEAR'] = 2;
                                                                        }
                                                                }
-                                                               if ($theKey == 'extra') {
+                                                               if ($theKey === 'extra') {
                                                                        if ($remove) {
                                                                                if (substr($fN, 0, strlen($deletedPrefixKey)) != $deletedPrefixKey) {
                                                                                        $statement = 'ALTER TABLE ' . $table . ' CHANGE ' . $fN . ' ' . $deletedPrefixKey . $fN . ' ' . $fV . ';';
index acc0965..bbf91a9 100644 (file)
@@ -69,11 +69,20 @@ class Tx_Identity_Provider_AbstractUuid implements Tx_Identity_ProviderInterface
        protected $deleteQueue = array();
 
        /**
+        * @var integer
+        */
+       protected $version;
+
+       /**
         * Sets the provider key
         * @param string $providerKey
         */
        public function __construct($providerKey) {
                $this->providerKey = $providerKey;
+
+               $this->version = class_exists('t3lib_utility_VersionNumber')
+                               ? t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version)
+                               : t3lib_div::int_from_ver(TYPO3_version);
        }
 
        /**
@@ -105,22 +114,18 @@ class Tx_Identity_Provider_AbstractUuid implements Tx_Identity_ProviderInterface
        public function validateIdentifier($identifier) {
                if (!strlen($identifier)) {
                        throw new InvalidArgumentException('Empty UUID given.', 1299013185);
-                       return false;
                }
                if (function_exists('uuid_is_valid') && !uuid_is_valid($identifier)) {
                        throw new InvalidArgumentException('Given UUID does not match the UUID pattern.', 1299013329);
-                       return false;
                }
                if (strlen($identifier) !== 36) {
                        throw new InvalidArgumentException('Lenghth of UUID has to be 36 characters.', 1299013335);
-                       return false;
                }
                $pattern = '/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i';
                if (!preg_match($pattern, $identifier)) {
                        throw new InvalidArgumentException('Given UUID does not match the UUID pattern.', 1299013339);
-                       return false;
                }
-               return true;
+               return TRUE;
        }
 
        /**
@@ -184,7 +189,12 @@ class Tx_Identity_Provider_AbstractUuid implements Tx_Identity_ProviderInterface
                if (!isset($GLOBALS['TCA'][$tablename])) {
                        throw new InvalidArgumentException('The tablename "' . $tablename . '" is not defined in the TCA.', 1299082184);
                }
-               if (!t3lib_div::testInt($uid)) {
+               if ($this->version < 4006000) {
+                       $invalidUid = !t3lib_div::testInt($uid);
+               } else {
+                       $invalidUid = !t3lib_utility_Math::canBeInterpretedAsInteger($uid);
+               }
+               if ($invalidUid) {
                        throw new InvalidArgumentException('The uid "' . $uid . '" is not an integer.', 1299082236);
                }
                $row = $this->db->exec_SELECTgetSingleRow(
@@ -279,7 +289,12 @@ class Tx_Identity_Provider_AbstractUuid implements Tx_Identity_ProviderInterface
                $identityField = $this->configuration[Tx_Identity_Configuration_IdentityProviderInterface::IDENTITY_FIELD];
                $this->validateIdentifier($uuid);
                t3lib_div::loadTCA($tablename);
-               if (isset($GLOBALS['TCA'][$tablename]) && t3lib_div::testInt($uid)) {
+               if ($this->version < 4006000) {
+                       $validUid = t3lib_div::testInt($uid);
+               } else {
+                       $validUid = t3lib_utility_Math::canBeInterpretedAsInteger($uid);
+               }
+               if (isset($GLOBALS['TCA'][$tablename]) && $validUid) {
                        if (isset($this->insertQueue[$uuid])) {
                                unset($this->insertQueue[$uuid]);
                        }
index fbc7265..1af18dc 100644 (file)
@@ -75,7 +75,7 @@ class Tx_Identity_Utility_Algorithms {
         * @throws InvalidArgumentException Throws an invalid argument exception, if the given namespace is not an uuid
         */
    static public function generateUUIDv5($namespace, $name) {
-        self::validateUUID($namespace);
+       // self::validateUUID($namespace);
 
         // Get hexadecimal components of namespace
         $nhex = str_replace(array('-','{','}'), '', $namespace);
@@ -125,6 +125,7 @@ class Tx_Identity_Utility_Algorithms {
        static public function generateRandomBytes($count) {
                $bytes = '';
 
+                       // TODO: use TYPO3's internal API to retrieve random bytes
                if (file_exists('/dev/urandom')) {
                        $bytes = file_get_contents('/dev/urandom', NULL, NULL, NULL, $count);
                }
index 391af19..7123e46 100644 (file)
@@ -17,13 +17,13 @@ class Tx_Identity_Utility_FieldDefinitions {
                        t3lib_div::loadTCA($table);
 
                        if (isset($GLOBALS['TCA'][$table])) {
-                               
+
                                if (isset($GLOBALS['TCA'][$table]['ctrl']['EXT']['identity'][Tx_Identity_Configuration_IdentityProviderInterface::KEY])) {
 
                                        $identityProviderKey = $GLOBALS['TCA'][$table]['ctrl']['EXT']['identity'][Tx_Identity_Configuration_IdentityProviderInterface::KEY];
                                        $identityProviderField = $identityProviders[$identityProviderKey][Tx_Identity_Configuration_IdentityProviderInterface::IDENTITY_FIELD];
                                        $identityConfigurationCheck->checkTableSpecificIdentityProviderConfiguration($table, $identityProviderKey);
-                                       
+
                                                // Adds field + index definition
                                        $definition['fields'][$identityProviderField] = $identityProviders[$identityProviderKey][Tx_Identity_Configuration_IdentityProviderInterface::IDENTITY_FIELD_CREATE_CLAUSE];
                                        $definition['keys'][$identityProviderField] = 'KEY ' . $identityProviderField . ' (' . $identityProviderField . ')';
@@ -33,7 +33,7 @@ class Tx_Identity_Utility_FieldDefinitions {
                                        $defaultProviderKey = $identityConfiguration[Tx_Identity_Configuration_IdentityProviderInterface::DEFAULT_PROVIDER];
                                        $defaultProviderField = $identityProviders[$defaultProviderKey][Tx_Identity_Configuration_IdentityProviderInterface::IDENTITY_FIELD];
                                        $identityConfigurationCheck->checkDefaultIdentityProviderConfiguration($defaultProviderKey);
-                                       
+
                                                // Adds field + index definition
                                        $definition['fields'][$defaultProviderField] = $identityProviders[$defaultProviderKey][Tx_Identity_Configuration_IdentityProviderInterface::IDENTITY_FIELD_CREATE_CLAUSE];
                                        $definition['keys'][$defaultProviderField] = 'KEY ' . $defaultProviderField . ' (' . $defaultProviderField . ')';
@@ -47,17 +47,17 @@ class Tx_Identity_Utility_FieldDefinitions {
                                        );
 
                                }
-                       } elseif ($table == 'sys_identity') {
+                       } elseif ($table === 'sys_identity') {
 
                                foreach ($identityProviders as $identityProviderKey=>$identityProviderConfiguration) {
                                        $identityConfigurationCheck->checkIdentityProviderConfiguration($identityProviderKey);
                                        $identityField = $identityProviderConfiguration[Tx_Identity_Configuration_IdentityProviderInterface::IDENTITY_FIELD];
                                        $identityFieldCreateClause = $identityProviderConfiguration[Tx_Identity_Configuration_IdentityProviderInterface::IDENTITY_FIELD_CREATE_CLAUSE];
-                                       
+
                                                // Adds field + index definition
                                        $definition['fields'][$identityField] = $identityFieldCreateClause;
                                        $definition['keys'][$identityField] = 'KEY ' . $identityField . ' (' . $identityField . ')';
-                                       
+
                                }
 
                        }
index 22efa62..fc15645 100644 (file)
@@ -38,6 +38,12 @@ if (t3lib_extMgm::isLoaded('identity')) {
  */
 class ext_update {
 
+       /** @var Tx_Identity_Install_Installer */
+       protected $installer;
+
+       /** @var Tx_Identity_Map */
+       protected $identityMap;
+
        /**
         * Defines whether the UPDATE! menu should be displayed or not.
         *
@@ -54,7 +60,6 @@ class ext_update {
        public function __construct() {
                if (t3lib_extMgm::isLoaded('identity')) {
                                // instantiate a light installer
-                               /* @var $this->installer Tx_Identity_Install_Installer */
                        $this->installer = t3lib_div::makeInstance('Tx_Identity_Install_Installer');
                        $this->identityMap = t3lib_div::makeInstance('Tx_Identity_Map');
                }
@@ -77,7 +82,7 @@ class ext_update {
 
                }
                else {
-                       $content .= $this->renderMessageOk();
+                       $content = $this->renderMessageOk();
                }
 
                        // display a notification also if missing table are found
@@ -114,6 +119,7 @@ class ext_update {
 
                        // get the table definitions
                $tableDefinitions = $this->installer->getFieldDefinitions_fileContent($fileContent);
+               /** @var $fieldDefinitionsUtility Tx_Identity_Utility_FieldDefinitions */
                $fieldDefinitionsUtility = t3lib_div::makeInstance('Tx_Identity_Utility_FieldDefinitions');
                $tableDefinitions = $fieldDefinitionsUtility->insertIdentityColumn($tableDefinitions);
                if (!count($tableDefinitions)) {
@@ -121,7 +127,7 @@ class ext_update {
                }
 
                        // Execute the statement if button submit has been pressed
-               if (t3lib_div::_GP('update') == 'doUpdate') {
+               if (t3lib_div::_GP('update') === 'doUpdate') {
 
                        $parameters = t3lib_div::_GP('TYPO3_INSTALL');
                        if (is_array($parameters['database_update'])) {
@@ -172,7 +178,7 @@ class ext_update {
         * @return      string  HTML to display
         */
        protected function renderMessageTable() {
-               $content .= '
+               $content = '
                        <div style="width: 600px; margin-top: 20px">
                                <div class="typo3-message message-information">
                                        <div class="message-header">'
@@ -212,7 +218,6 @@ class ext_update {
                                .t3-install-form-label-after label {
                                        padding-left: 1em;
                                }
-                               genera...1016810 (line 117)
                                .t3-install-form-label-after label, .t3-install-form-label-above label {
                                        display: block;
                                        float: none;
@@ -240,7 +245,7 @@ class ext_update {
        }
 }
 
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/identity/class.ext_update.php']) {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/identity/class.ext_update.php']);
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/identity/class.ext_update.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/identity/class.ext_update.php']);
 }
 ?>
index 2c3c6b6..eaf0f9c 100644 (file)
@@ -31,6 +31,7 @@ $EM_CONF[$_EXTKEY] = array(
        'version' => '0.0.0',
        'constraints' => array(
                'depends' => array(
+                       'typo3' => '4.5.0-4.7.99',
                ),
                'conflicts' => array(
                ),
index 72c5574..4542996 100644 (file)
@@ -26,7 +26,9 @@
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
-if (!defined ("TYPO3_MODE"))    die ('Access denied.');
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
 
 $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_install.php'] = t3lib_extMgm::extPath($_EXTKEY) . 'Classes/Xclass/class.ux_t3lib_install.php';
 $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/install/mod/class.tx_install.php'] = t3lib_extMgm::extPath($_EXTKEY) . 'Classes/Xclass/class.ux_tx_install.php';
index 4a2d3ad..8cf3fbf 100644 (file)
@@ -26,7 +26,9 @@
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 
-if (!defined ("TYPO3_MODE"))    die ('Access denied.');
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
 
 foreach ($GLOBALS['TCA'] as $tablename=>$configuration) {
        t3lib_div::loadTCA($tablename);