#106942Wrong comparison operators end in php warnings
Description
In typo3/cms-felogin/Classes/Configuration/RecoveryConfiguration.php the comparison operator ?: is used in many places.
For example Line 98:
$lifetimeInHours = $this->settings['forgotLinkHashValidTime'] ?: 12;
But shouldn’t it be the ?? operator?
The ?: leads to corresponding PHP warnings if e.g. $this->settings[‘forgotLinkHashValidTime’] is not set.
Reviews 4
Related issues 1
History 1215
-
Garvin Hicking commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-06-24T07:00:21+00:00" > 06/24/25, 07:00 </span> -
Thomas Rokohl commented <span data-processor="relativetime" data-value="2025-06-24T07:05:59+00:00" > 06/24/25, 07:05 </span>
I had a faulty configuration and had not yet installed the felogin typescript.
Unfortunately, I couldn’t tell from the warning what the problem was.
?: triggers a warning if the key in the array is not defined ?? does the same but also returns the else if the key is not defined.
?: does not have the desired effect here in my opinion
-
Thomas Rokohl commented <span data-processor="relativetime" data-value="2025-06-24T07:12:14+00:00" > 06/24/25, 07:12 </span>
for example:
$fromAddress = $this->settings['email_from'] ?: $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']; if (empty($fromAddress)) { throw new IncompleteConfigurationException( 'Either "$GLOBALS[\'TYPO3_CONF_VARS\'][\'MAIL\'][\'defaultMailFromAddress\']" or extension key "plugin.tx_felogin_login.settings.email_from" cannot be empty!', 1573825624 ); }the fallback doesn’t work if warnings are on.
-
Thomas Rokohl commented <span data-processor="relativetime" data-value="2025-06-24T07:30:38+00:00" > 06/24/25, 07:30 </span>
perhaps this:
$lifetimeInHours = $this->settings['forgotLinkHashValidTime'] ?? null; if(!$lifetimeInHours) { throw new IncompleteConfigurationException( 'plugin.tx_felogin_login.settings.forgotLinkHashValidTime must be set, you have forgotten to add the typoscript?', 1750750125 );is a more convenient solution, isn’t it?
-
Gerrit Code Review pushed patch set 1 for main to change 89837 status
Needs FeedbackUnder Review <span data-processor="relativetime" data-value="2025-06-24T09:48:08+00:00" > 06/24/25, 09:48 </span> -
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-06-24T09:51:17+00:00" > 06/24/25, 09:51 </span>
I’ve pushed a patch for this so that the checks can better apply fallbacks also on unset keys.
Please note however that normally, EXT:felogin uses “addTypoScriptSetup” on its own to ensure its TypoScript is loaded, do you know what you changed so that this could not take effect?
-
Thomas Rokohl commented <span data-processor="relativetime" data-value="2025-06-24T10:02:57+00:00" > 06/24/25, 10:02 </span>
great, but two things:
My approach serves to improve error detection.
First, if you set a live enviroment, normaly warning are not displayed, so perhabs you don’t see the missing key in array warning.Second: Line 158 throws also a missing key exception if the typoscript is missing.
If you fix this warning, i get a good note to find the mistage:Key "plugin.tx_felogin_login.settings.email.templateName" cannot be empty!
I think it would be better if a hard exeception was thrown if the typoscript is not loaded.
-
Gerrit Code Review pushed patch set 2 for main to change 89837 <span data-processor="relativetime" data-value="2025-06-24T15:38:43+00:00" > 06/24/25, 15:38 </span>
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 89857 <span data-processor="relativetime" data-value="2025-06-24T18:08:17+00:00" > 06/24/25, 18:08 </span>
-
Garvin Hicking commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-06-24T18:30:08+00:00" > 06/24/25, 18:30 </span>Applied in changeset commit:09bdc38d7719eed1c5c2aeb71261fba93bf4356f.
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-06-24T21:58:10+00:00" > 06/24/25, 21:58 </span>
Sorry, I only read your reply now. I understand your proposal, but I think the lifetime is something that could fallback to a “sane” default at this place. If the whole typoscript is missing, like in your case, you should actually get the exception from the missing mailname now that the PHP warning no longer occurs.
I hope this also works out for you? -
Thomas Rokohl commented <span data-processor="relativetime" data-value="2025-06-25T08:21:45+00:00" > 06/25/25, 08:21 </span>
Line 158 is still the problem (see above)
$this->mailTemplateName = (string)$this->settings['email']['templateName']; -
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-06-25T20:48:53+00:00" > 06/25/25, 20:48 </span>
Ah, ok. I only paid attention to the “?:” operator and didn’t check others.
We’ll need a new follow-up issue for this.
-
Garvin Hicking changed Related to #106994 <span data-processor="relativetime" data-value="2025-06-27T07:17:25+00:00" > 06/27/25, 07:17 </span>
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:27:42+00:00" > 12/02/25, 14:27 </span>
This is actually in place to safeguard against settings that have 0/false in place, so that “12” is guaranteed in these cases.
The setting should usually always exists and should fallback to flexform/typoscript defaults – could you mention the details under which you have this key be undefined?