-
-
Notifications
You must be signed in to change notification settings - Fork 60
fix for Cannot use bool as array #1586
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR fixes a PHP error "Cannot use bool as array" by updating array destructuring patterns in while loops. The issue occurs when fetchRow() returns false (indicating no more rows) but the code attempts to destructure it as an array.
- Replaced direct array destructuring assignments in while loop conditions with proper null checks
- Added intermediate variable assignments to safely handle
fetchRow()return values - Maintained existing logic flow while preventing the type error
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| htdocs/xoops_lib/modules/protector/admin/center.php | Fixed array destructuring in database result loops and corrected control flow logic |
| htdocs/pda.php | Updated while loop to safely handle fetchRow return value |
| htdocs/modules/system/include/update.php | Fixed array destructuring in template ID collection loop |
| htdocs/modules/system/class/maintenance.php | Added proper null check for fetchRow in database dump method |
| htdocs/modules/profile/class/visibility.php | Updated field ID collection loop to handle fetchRow safely |
| htdocs/kernel/session.php | Fixed session data retrieval with proper null checking |
| htdocs/class/xoopstree.php | Updated multiple tree traversal methods to handle fetchRow safely |
| htdocs/class/model/stats.php | Fixed array destructuring in statistics counting methods |
| htdocs/class/model/joint.php | Updated link count retrieval to handle fetchRow safely |
| htdocs/banners.php | Fixed multiple banner statistics loops to handle fetchRow safely |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…ature/Cannot_use_bool_as_array
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.
Pull Request Overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if ($db->isResultSet($result)) { | ||
| $row = $db->fetchRow($result); | ||
| if (false !== $row) { | ||
| [$ip] = $row; |
Copilot
AI
Oct 9, 2025
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.
The logic is inverted. The condition should check !$db->isResultSet($result) as in the original code. isResultSet() returns true for valid result sets, but you want to process the data when you have a valid result set, not when you don't.
No description provided.