Skip to content
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

Merged
merged 1 commit into from
May 17, 2024

Conversation

bwalkerl
Copy link
Contributor

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.

@bwalkerl bwalkerl requested a review from Peterburnett April 12, 2024 05:50
$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') {
Copy link
Contributor

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.

Copy link
Contributor Author

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()?

Copy link
Contributor Author

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.

Copy link
Contributor

@Peterburnett Peterburnett left a 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

@bwalkerl bwalkerl force-pushed the factor-token-version-457 branch from 17438fa to 179fa1c Compare April 15, 2024 03:35
@danmarsden danmarsden merged commit a040bc5 into MOODLE_400_STABLE May 17, 2024
16 checks passed
@danmarsden danmarsden deleted the factor-token-version-457 branch May 17, 2024 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants