Project

General

Profile

Actions

Bug #67413

closed

Database Analyzer complains about sets with values having uppercase letters

Added by Stephan Großberndt over 9 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Install Tool
Target version:
-
Start date:
2015-06-11
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Definition in ext_tables.sql:

subtype set('Tx_MyExt_Domain_Model_Xyz','Tx_MyExt_Domain_Model_Abc','') NOT NULL DEFAULT '',

In TYPO3 4.7 this worked without problems (MySQL has no problems with upper- or mixed case in set), in TYPO3 6.2 the database compare complains and wants to change the case of all set entries to lowercase:

subtype set('tx_myext_domain_model_xyz','tx_myext_domain_model_abc','') NOT NULL DEFAULT '',

Luckily I spotted this before applying all database changes, otherwise the subtypes had been '' in all records now..

The problem is in typo3\sysext\install\Classes\Service\SqlSchemaMigrationService.php : SqlSchemaMigrationService->getDatabaseExtra()

// Lowercase the field type to surround false-positive schema changes to be
// reported just because of different caseing of characters
// The regex does just trigger for the first word followed by round brackets
// that contain a length. It does not trigger for e.g. "PRIMARY KEY" because
// "PRIMARY KEY" is being returned from the DB in upper case.
$fieldC = preg_replace_callback(
    '/^([a-zA-Z0-9]+\(.*\))(\s)(.*)/',
    create_function(
        '$matches',
        'return strtolower($matches[1]) . $matches[2] . $matches[3];'
    ),
    $fieldC
);

This should lead to lowercasing for fieldtypes with a length e.g. int (11) but matches for set or enum too currently.

By changing the regexp to match only fields with a number in brackets this is solved:

// Lowercase the field type to surround false-positive schema changes to be
// reported just because of different caseing of characters
// The regex does just trigger for the first word followed by round brackets
// that contain a length. It does not trigger for e.g. "PRIMARY KEY" because
// "PRIMARY KEY" is being returned from the DB in upper case.
$fieldC = preg_replace_callback(
    '/^([a-zA-Z0-9]+\(\d*\))(\s)(.*)/',
    create_function(
        '$matches',
        'return strtolower($matches[1]) . $matches[2] . $matches[3];'
    ),
    $fieldC
);
Actions #1

Updated by Stephan Großberndt over 9 years ago

Since DECIMAL(11, 2) is valid too, matching on integers only is not possible.

Instead lowercasing should happen only for the part in front of the brackets:

$fieldC = preg_replace_callback(
    '/^([a-zA-Z0-9]+)(\(.*\)\s.*)/',
    create_function(
        '$matches',
        'return strtolower($matches[1]) . $matches[2];'
    ),
    $fieldC
);
Actions #2

Updated by Stephan Großberndt over 9 years ago

  • Status changed from New to In Progress
Actions #3

Updated by Gerrit Code Review over 9 years ago

  • Status changed from In Progress to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40176

Actions #4

Updated by Gerrit Code Review over 9 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40176

Actions #5

Updated by Gerrit Code Review over 9 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/40463

Actions #6

Updated by Stephan Großberndt over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF