Skip to content

Conversation

@mambax7
Copy link
Collaborator

@mambax7 mambax7 commented Jan 13, 2026

Summary by CodeRabbit

  • Chores

    • Increased minimum PHP requirement to 7.4.0 and minimum XOOPS to 2.5.12.
  • Infrastructure

    • Configuration schema updated to support larger identifier values.
  • Improvements

    • Improved reliability of database write operations across install, uninstall, module install, and profile setup paths to reduce failures during setup and updates.

Copilot AI review requested due to automatic review settings January 13, 2026 02:56
Copy link
Contributor

Copilot AI left a 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 improves the installation process by updating minimum PHP and XOOPS version requirements and standardizing database operations to use the exec() method for write operations (INSERT, UPDATE, DELETE, DDL) instead of the query() method.

Changes:

  • Updated minimum PHP version requirement from 5.6.0 to 7.4 and minimum XOOPS version from 2.5.11 to 2.5.12
  • Replaced query() with exec() for all mutating database operations across installation, uninstallation, and core model files
  • Removed conditional logic that previously chose between query() and exec() based on force flags, now consistently using exec() for write operations

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
htdocs/xoops_lib/modules/protector/xoops_version.php Updated minimum PHP version to 7.4 and minimum XOOPS version to 2.5.12
htdocs/xoops_lib/modules/protector/onuninstall.php Changed DROP TABLE query from query() to exec()
htdocs/xoops_lib/modules/protector/oninstall.php Changed CREATE TABLE query from query() to exec()
htdocs/modules/system/admin/modulesadmin/modulesadmin.php Changed table creation query from query() to exec()
htdocs/modules/profile/include/install.php Changed INSERT queries from query() to exec()
htdocs/class/model/write.php Standardized all write operations (INSERT, UPDATE, DELETE) to use exec() method with commented-out old conditional logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 335 to 336
// $queryFunc = empty($force) ? 'query' : 'exec';
$queryFunc = 'exec';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commented-out lines should be removed rather than kept as comments. The old logic that conditionally chose between 'query' and 'exec' based on the $force parameter has been replaced with always using 'exec', which is the correct approach for DELETE operations. Leaving commented code reduces maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines 375 to 376
// $queryFunc = empty($force) ? 'query' : 'exec';
$queryFunc = 'exec';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commented-out lines should be removed rather than kept as comments. The old logic that conditionally chose between 'query' and 'exec' based on the $force parameter has been replaced with always using 'exec', which is the correct approach for UPDATE operations. Leaving commented code reduces maintainability.

Copilot uses AI. Check for mistakes.
$modversion['module_website_name'] = 'XOOPS';
$modversion['min_php'] = '5.6.0';
$modversion['min_xoops'] = '2.5.11';
$modversion['min_php'] = '7.4';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version string '7.4' is inconsistent with the previous format '5.6.0' and other modules in the codebase that use three-component version strings (e.g., '5.6.0' in pm/xoops_version.php and profile/xoops_version.php). While functionally equivalent in version_compare(), it's better to maintain consistency with the established format. Consider using '7.4.0' instead.

Suggested change
$modversion['min_php'] = '7.4';
$modversion['min_php'] = '7.4.0';

Copilot uses AI. Check for mistakes.
Comment on lines 308 to 309
// $queryFunc = empty($force) ? 'query' : 'exec';
$queryFunc = 'exec';
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commented-out lines should be removed rather than kept as comments. The old logic that conditionally chose between 'query' and 'exec' based on the $force parameter has been replaced with always using 'exec', which is the correct approach for DELETE operations. Leaving commented code reduces maintainability.

Copilot uses AI. Check for mistakes.
mambax7 and others added 2 commits January 12, 2026 23:00
- Remove commented-out $force conditional lines (Copilot review feedback)
- Eliminate $queryFunc variable; call ->exec() directly for all writes
- Remove redundant $queryFunc reassignments in insert() method
- Use '7.4.0' for min_php to match codebase three-component format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Replaced multiple database write calls from query() to exec() across write operations and install/uninstall routines; changed config.conf_id and configoption.conf_id column types from smallint(5) unsigned to int(10) unsigned; updated protector module requirements to PHP 7.4.0 and XOOPS 2.5.12.

Changes

Cohort / File(s) Summary
Write model
htdocs/class/model/write.php
Removed dynamic selection of query function; all insert/delete/deleteAll/updateAll now call $this->handler->db->exec($sql) directly.
Install/uninstall & module helpers
htdocs/modules/profile/include/install.php, htdocs/modules/system/admin/modulesadmin/modulesadmin.php, htdocs/xoops_lib/modules/protector/oninstall.php, htdocs/xoops_lib/modules/protector/onuninstall.php
Replaced query(...) calls with exec(...) for SQL execution in profile install helpers, module table creation, and protector install/uninstall flows.
Schema
htdocs/install/sql/mysql.structure.sql
Changed config.conf_id and configoption.conf_id from smallint(5) unsignedint(10) unsigned.
Module metadata
htdocs/xoops_lib/modules/protector/xoops_version.php
Bumped min_php 5.6.0 → 7.4.0 and min_xoops 2.5.11 → 2.5.12 in protector module metadata.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I nibble code beneath moonlight's glow,
Swapped query for exec in a rhythmic hop,
Grew conf_id taller so rows can grow,
Protector asks for newer PHP on top,
A happy rabbit hops—commit and go! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Improve installation' is vague and generic, using non-descriptive language that does not convey the specific technical changes in the changeset. Consider a more specific title that reflects the actual changes, such as 'Refactor database write operations to use exec() method' or 'Update database schema and installer dependencies', to better communicate the primary intent to reviewers.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
htdocs/class/model/write.php (2)

329-329: Inconsistent SQL quoting: missing backticks around table name.

Line 303 wraps the table name in backticks (DELETE FROM \...``), but line 329 does not. For consistency and to protect against reserved word conflicts, consider adding backticks here as well.

Proposed fix
-        $sql = 'DELETE FROM ' . $this->handler->table;
+        $sql = 'DELETE FROM `' . $this->handler->table . '`';

241-241: Consider: $force parameter is now unused.

With the migration to exec(), the $force parameter no longer affects behavior in insert(), delete(), deleteAll() (for non-object mode), and updateAll(). The parameter is retained for backward compatibility, which is reasonable for a public API.

If this is intentional for BC, consider adding a brief inline comment or deprecation notice. Otherwise, if breaking changes are acceptable, the parameter could be removed in a future major version.

Also applies to: 291-291, 317-317, 353-353


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@htdocs/install/sql/mysql.structure.sql`:
- Line 160: configoption.conf_id is defined as smallint(5) unsigned while
config.conf_id is int(10) unsigned, risking mismatch when config.conf_id >
65535; update the configoption table definition to change the column conf_id
from smallint(5) unsigned to int(10) unsigned (and adjust any index definitions
referencing configoption.conf_id if necessary) so both tables use the same type
and width for conf_id.
🧹 Nitpick comments (2)
htdocs/class/model/write.php (2)

264-266: Unused variable assignment.

The static analysis correctly flags that $result is assigned but not used beyond the condition check. You can simplify this:

♻️ Proposed simplification
-            if (!$result = $this->handler->db->exec($sql)) {
+            if (!$this->handler->db->exec($sql)) {
                 return false;
             }

276-278: Same pattern: unused variable assignment.

Similar to line 264, the $result variable is assigned but only used in the condition check.

♻️ Proposed simplification
-            if (!$result = $this->handler->db->exec($sql)) {
+            if (!$this->handler->db->exec($sql)) {
                 return false;
             }

- configoption.conf_id: smallint(5) → int(10) unsigned to match
  config.conf_id, preventing data integrity issues past 65535 rows
- write.php insert(): remove unused $result assignment from exec()
  calls (INSERT and UPDATE branches) — value was only checked in
  the if-condition, never used afterward

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 9, 2026

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.

1 participant