twofactor_gauthenticator icon indicating copy to clipboard operation
twofactor_gauthenticator copied to clipboard

Multiple PHP warnings under PHP 8.1.27

Open ozgurkazancci opened this issue 1 year ago • 8 comments

PHP version: 8.1.27 Roundcube version: 1.6.6

Hi, and first of all, thanks for such a good idea/plugin. I have activated and enabled the plugin. Logged out to try it, however I got the following varying PHP warnings;

PHP Warning:  preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 7

PHP Warning:  preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 75

PHP Warning:  Trying to access array offset on value of type null in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 288
PHP Warning:  Trying to access array offset on value of type null in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 294
PHP Warning:  Trying to access array offset on value of type null in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 297
PHP Warning:  Trying to access array offset on value of type null in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 318
PHP Warning:  Trying to access array offset on value of type null in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 328
PHP Warning:  Trying to access array offset on value of type null in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 342

PHP Warning:  Undefined array key "twofactor_gauthenticator_2FA_login" in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 239

PHP Warning:  Trying to access array offset on value of type null in /plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 239

Just wanted to report these all here.

Regards.

ozgurkazancci avatar Feb 11 '24 13:02 ozgurkazancci

Hi, I've also checked all versions of php 8.* and a similar warning is returned on each of them:

[16-Feb-2024 09:28:30 Europe/Warsaw] PHP Warning: Undefined array key "twofactor_gauthenticator" in /var/www/html/roundcube/plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 413
[16-Feb-2024 09:28:30 Europe/Warsaw] PHP Warning: Trying to access array offset on value of type null in /var/www/html/roundcube/plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 131

Roundcube version: 1.6.6

lukaszmarcola avatar Feb 16 '24 10:02 lukaszmarcola

I think this project is abandoned, this guy is only merging pull requests and everything looks crappy.

f1-outsourcing avatar May 12 '24 09:05 f1-outsourcing

not abandoned, just fake news 😸

alexandregz avatar May 19 '24 19:05 alexandregz

for example, looks her "opinion": he don't understand code -qr codes are generated locally using JS, easy to see- and try to call that others code, not only mine, is "crappy"

https://github.com/alexandregz/twofactor_gauthenticator/issues/194

Another one: https://github.com/alexandregz/twofactor_gauthenticator/issues/190#issuecomment-2106172903

alexandregz avatar May 19 '24 19:05 alexandregz

About first comment: All this are just warnings because try to access to preferences first time, without prefs. You can skip these.

About second: I can't reproduce warnings (with php 8.0.8)

alexandregz avatar May 19 '24 19:05 alexandregz

About first comment: All this are just warnings because try to access to preferences first time, without prefs. You can skip these.

About second: I can't reproduce warnings (with php 8.0.8)

These warnings appear from PHP 8.1 version onwards and should be fixed as in future PHP versions the affected code won't work anymore. I encounter these two warnings when running RoundCube and this plugin with PHP version 8.1.

[25-Jun-2024 01:54:54 UTC] PHP Warning:  Undefined array key "twofactor_gauthenticator_2FA_login" in /var/www/roundcube/plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 184
[25-Jun-2024 01:54:54 UTC] PHP Warning:  Undefined array key "twofactor_gauthenticator_login" in /var/www/roundcube/plugins/twofactor_gauthenticator/twofactor_gauthenticator.php on line 184

CodeShakingSheep avatar Jun 25 '24 03:06 CodeShakingSheep

These warnings appear from PHP 8.1 version onwards and should be fixed as in future PHP versions the affected code won't work anymore. I encounter these two warnings when running RoundCube and this plugin with PHP version 8.1.

These are unfortunately problems with plugins that are not production ready and are cobbled together so that they barely work.

Try changing line 184: elseif($rcmail->task !== 'login' ! $_SESSION['twofactor_gauthenticator_2FA_login'] >= $_SESSION['twofactor_gauthenticator_login'])

into: elseif($rcmail->task !== 'login' && isset($_SESSION['twofactor_gauthenticator_2FA_login']) && isset($_SESSION['twofactor_gauthenticator_login']) && ! $_SESSION['twofactor_gauthenticator_2FA_login'] >= $_SESSION['twofactor_gauthenticator_login'])

kam821 avatar Aug 10 '24 17:08 kam821