-
Notifications
You must be signed in to change notification settings - Fork 205
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
[Skip] payment in Setup wizard when no payment is active #2468
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe changes in this pull request involve renaming the protected variable Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
includes/Admin/SetupWizard.php
(10 hunks)includes/Admin/SetupWizardNoWC.php
(2 hunks)includes/Vendor/SetupWizard.php
(16 hunks)
🔇 Additional comments (1)
includes/Admin/SetupWizardNoWC.php (1)
76-82
: Consistent Use of $this->current_step
The variable $this->current_step
is correctly used to reference the current step, aligning with the updated property name and maintaining consistency across the setup wizard implementation.
/** @var string Current Step */ | ||
protected string $current_step = ''; |
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.
Ensure PHP Version Compatibility with Typed Properties
The use of typed properties, such as protected string $current_step = '';
, requires PHP 7.4 or higher. Please confirm that the project's minimum PHP version supports this feature to avoid compatibility issues.
|
||
// get step from url | ||
if ( isset( $_GET['_admin_sw_nonce'], $_GET['step'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_admin_sw_nonce'] ) ), 'dokan_admin_setup_wizard_nonce' ) ) { | ||
$this->step = sanitize_key( wp_unslash( $_GET['step'] ) ); | ||
$this->current_step = sanitize_key( wp_unslash( $_GET['step'] ) ) ?? current( array_keys( $this->steps ) ); |
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.
Confirm PHP Version Compatibility with Null Coalescing Operator
The use of the null coalescing operator ??
in $this->current_step = sanitize_key( wp_unslash( $_GET['step'] ) ) ?? current( array_keys( $this->steps ) );
requires PHP 7.0 or higher. Please verify that the project's minimum PHP version supports this operator.
@@ -12,7 +12,7 @@ | |||
class SetupWizard { | |||
|
|||
/** @var string Currenct Step */ | |||
protected $step = ''; | |||
protected string $current_step = ''; |
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.
Ensure PHP Version Compatibility with Typed Properties
The use of typed properties, such as protected string $current_step = '';
, requires PHP 7.4 or higher. Please confirm that the project's minimum PHP version supports this feature to avoid compatibility issues.
@@ -292,7 +292,7 @@ | |||
|
|||
return add_query_arg( | |||
[ | |||
'step' => $keys[ array_search( $this->step, array_keys( $this->steps ), true ) + 1 ], | |||
'step' => $keys[ array_search( $this->current_step, array_keys( $this->steps ), true ) + 1 ], |
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.
Handle Potential Array Offset Error in get_next_step_link
Method
When calculating the next step, array_search( $this->current_step, array_keys( $this->steps ), true ) + 1
may exceed the bounds of the $keys
array if $this->current_step
is the last element. This could lead to an undefined index notice. Consider adding a check to ensure the computed index exists in $keys
before accessing it.
Apply this diff to handle the array offset error:
public function get_next_step_link() {
$keys = array_keys( $this->steps );
- return add_query_arg(
- [
- 'step' => $keys[ array_search( $this->current_step, array_keys( $this->steps ), true ) + 1 ],
- '_admin_sw_nonce' => wp_create_nonce( 'dokan_admin_setup_wizard_nonce' ),
- ]
- );
+ $current_index = array_search( $this->current_step, $keys, true );
+ if ( false !== $current_index && isset( $keys[ $current_index + 1 ] ) ) {
+ $next_step = $keys[ $current_index + 1 ];
+ } else {
+ $next_step = '';
+ }
+ return add_query_arg(
+ [
+ 'step' => $next_step,
+ '_admin_sw_nonce' => wp_create_nonce( 'dokan_admin_setup_wizard_nonce' ),
+ ]
+ );
}
Committable suggestion skipped: line range outside the PR's diff.
All Submissions:
Changes proposed in this Pull Request:
Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
Changelog entry
Title
Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.
Before Changes
Describe the issue before changes with screenshots(s).
After Changes
Describe the issue after changes with screenshot(s).
Feature Video (optional)
Link of detailed video if this PR is for a feature.
PR Self Review Checklist:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Refactor