-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix factor token version #457 #458
Conversation
factor/token/version.php
Outdated
$plugin->requires = 2022041908; // Support Moodle 4.0 and higher. | ||
$plugin->component = 'factor_token'; | ||
$plugin->release = 2022011700; | ||
$plugin->maturity = MATURITY_STABLE; | ||
$plugin->dependencies = ['tool_mfa' => 2019102400]; | ||
|
||
// Fix version numbers that are higher than 4.3 core. | ||
if (!during_initial_install() && get_config('factor_token', 'version') >= '2023100900') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This string/int comparison doesnt feel quite right. Can you verify the type and do an explicit cast if required. Having it hardcoded as a string feels wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Peterburnett
I copied from string part from the example as get_config('factor_token', 'version') is returning a string, but that's a good point.
This is running on every page so we'd want to go with the most efficient comparison. What do you think would be most efficient - leaving it as a string or casting with (int) or intval()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some testing I ended up going with (int) get_config('factor_token', 'version') >= 2023100900 as the difference was almost negligible compared to the other check and getting the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment around string/int comparison
17438fa
to
179fa1c
Compare
Based on the examples mentioned in #457
Doesn't feel ideal to do this in version.php, but appears to be the least disruptive option.