-
Notifications
You must be signed in to change notification settings - Fork 206
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: setup store country state validation #2550
base: develop
Are you sure you want to change the base?
Conversation
Warning Rate limit exceeded@osmansufy has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 36 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThis pull request refactors the internal logic of the Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant SW as SetupWizard
participant V as Validator
U->>SW: Submit store setup data
SW->>SW: Extract $country and $state from address array
SW->>V: Validate state if country supports states
V-->>SW: Return validation outcome
SW->>U: Return success or error response
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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: 0
🧹 Nitpick comments (3)
includes/Vendor/SetupWizard.php (3)
488-491
: Improve variable declarations and fix spacing issues.The variable declarations improve code readability, but there are some style issues to fix.
- $country = $dokan_settings['address']['country'] ; - $state = $dokan_settings['address']['state']; - $country_has_states = isset( $states[ $country ] ); - $state_is_empty = empty( $state ); // Validating filed. + $country = $dokan_settings['address']['country']; + $state = $dokan_settings['address']['state']; + $country_has_states = isset( $states[ $country ] ); + $state_is_empty = empty( $state );🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 488-488:
Space found before semicolon; expected "];" but found "] ;"
509-515
: Fix spacing in conditional checks and improve state validation.The state validation logic has been improved, but there are spacing issues in the conditions.
- } elseif ( ( $country_has_states && count( $states[ $country ] ) > 0 && $state_is_empty) ) { + } elseif ( ( $country_has_states && count( $states[ $country ] ) > 0 && $state_is_empty ) ) { $is_valid_form = false; $_POST['error_address[state]'] = 'error'; - } elseif ( ! $country_has_states && $state_is_empty ) { + } elseif ( ! $country_has_states && $state_is_empty ) { $is_valid_form = false; $_POST['error_address[state]'] = 'error'; }🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 509-509:
Expected 1 space after "&&"; 2 found
[failure] 509-509:
Expected 1 space before close parenthesis; 0 found
492-515
: Consider architectural improvements for validation handling.The current validation implementation has several areas for improvement:
- Using $_POST for error storage mixes concerns and could lead to conflicts
- Error messages are hardcoded and not internationalized
- Validation logic could be extracted into a separate method for reusability
Consider:
- Creating a dedicated error handling class/structure
- Extracting validation logic into a separate method
- Using WordPress internationalization for error messages
- Adding input sanitization checks
Would you like me to provide a code example implementing these improvements?
🧰 Tools
🪛 GitHub Check: Run PHPCS inspection
[failure] 509-509:
Expected 1 space after "&&"; 2 found
[failure] 509-509:
Expected 1 space before close parenthesis; 0 found
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
includes/Vendor/SetupWizard.php
(2 hunks)
🧰 Additional context used
🪛 GitHub Check: Run PHPCS inspection
includes/Vendor/SetupWizard.php
[failure] 488-488:
Space found before semicolon; expected "];" but found "] ;"
[failure] 509-509:
Expected 1 space after "&&"; 2 found
[failure] 509-509:
Expected 1 space before close parenthesis; 0 found
🪛 GitHub Actions: Inspections
includes/Vendor/SetupWizard.php
[error] 1-1: Space found before semicolon; expected '];' but found '] ;'
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: e2e tests (3, 3)
- GitHub Check: e2e tests (2, 3)
- GitHub Check: e2e tests (1, 3)
- GitHub Check: api tests (1, 1)
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