Actions
Bug #93890
closedMove email check in LegacyLinkNotationConverter to the end
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2021-04-09
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Description
Problem¶
On a page with many links the check validEmail()
in \TYPO3\CMS\Core\LinkHandling\LegacyLinkNotationConverter
(line 74) takes many server resources.
The check for validEmail
is at the beginning and mostly the link parameters are e.g. page UIDs (integer values).
So, the check will call some libraries and checks that will cost many resources.
Log output from typo3.org:
[09-Apr-2021 11:40:52 Europe/Berlin] PHP 191. TYPO3\CMS\Core\LinkHandling\LegacyLinkNotationConverter->resolve($linkParameter = '#transcript-1:02:56') /home/t3o-prod/ci/releases/26/private/typo3/sysext/core/Classes/LinkHandling/LinkService.php:87 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 192. TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($email = '') /home/t3o-prod/ci/releases/26/private/typo3/sysext/core/Classes/LinkHandling/LegacyLinkNotationConverter.php:74 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 193. Egulias\EmailValidator\EmailValidator->isValid($email = '', $emailValidation = class Egulias\EmailValidator\Validation\RFCValidation { private $parser = class Egulias\EmailValidator\EmailParser { protected $warnings = [...]; protected $domainPart = ''; protected $localPart = ''; protected $lexer = class Egulias\EmailValidator\EmailLexer { ... }; protected $localPartParser = class Egulias\EmailValidator\Parser\LocalPart { ... }; protected $domainPartParser = class Egulias\EmailValidator\Parser\DomainPart { ... } }; private $warnings = []; private $error = NULL }) /home/t3o-prod/ci/releases/26/private/typo3/sysext/core/Classes/Utility/GeneralUtility.php:856 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 194. Egulias\EmailValidator\Validation\RFCValidation->isValid($email = '', $emailLexer = class Egulias\EmailValidator\EmailLexer { protected $charValue = ['(' => 49, ')' => 261, '<' => 272, '>' => 273, '[' => 262, ']' => 263, ':' => 265, ';' => 275, '@' => 64, '\' => 92, '/' => 278, ',' => 274, '.' => 46, '\'' => 39, '`' => 96, '"' => 34, '-' => 264, '::' => 26' => 269, '67, ' ' => 268, ' ' => 270, ' ' => 301, 'IPv6' => 271, '{' => 276, '}' => 277, '' => NULL, '\0' => 0]; protected $hasInvalidTokens = FALSE; protected $previous = ['value' => '', 'type' => NULL, 'position' => 0]; public $token = ['value' => '', 'type' => NULL, 'position' => 0]; public $lookahead = NULL; private ${Doctrine\Common\Lexer\AbstractLexer}input = ''; private ${Doctrine\Common\Lexer\AbstractLexer}tokens = []; private ${Doctrine\Common\Lexer\AbstractLexer}position = 0; private ${Doctrine\Common\Lexer\AbstractLexer}peek = 0; private ${Doctrine\Common\Lexer\AbstractLexer}regex = '/([a-zA-Z_]+[46]?)|([^\\x00-\\x7F])|([0-9]+)|(\\r\\n)|(::)|(\\s+?)|(.)|[\\xA0-\\xff]+/iu' }) /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/EmailValidator.php:37 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 195. Egulias\EmailValidator\EmailParser->parse($str = '') /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/Validation/RFCValidation.php:30 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 196. Egulias\EmailValidator\Parser\DomainPart->parse($domainPart = '') /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/EmailParser.php:70 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 197. Egulias\EmailValidator\Parser\DomainPart->performDomainStartChecks() /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/Parser/DomainPart.php:49 [09-Apr-2021 11:40:52 Europe/Berlin] PHP 198. Egulias\EmailValidator\Parser\DomainPart->checkEmptyDomain() /home/t3o-prod/ci/releases/26/vendor/egulias/email-validator/src/Parser/DomainPart.php:74
Solution¶
Move the check for a validEmail()
to the end and all checks for string comparisons like strpos()
to the begin.
It takes less resources checking if it's a page UID or anchors. The check for email address should be at the end.
Actions