Skip to content

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Oct 20, 2025

Summary by CodeRabbit

  • Chores

    • Relaxed database package version constraint to allow a wider range of compatible releases
    • Updated Redis cluster image references used in local orchestration
    • Removed local adminer service from docker-compose
  • Tests

    • Reorganized and refactored benchmarking tests and setup (namespaces, class names, and adapter adjustments)
    • Minor formatting, import, and global-call adjustments across test suites

@coderabbitai
Copy link

coderabbitai bot commented Oct 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

composer.json relaxes the utopia-php/database constraint from "2." to "". Tests under tests/Abuse/Bench were moved to namespace Utopia\Tests\Bench and several classes renamed (DatabaseBench→Database, RedisBench→Redis, RedisClusterBench→RedisCluster). tests/Abuse/Bench/Base.php adds imports and replaces some calls with global-qualified functions. tests/Abuse/Bench/Database.php switches from a MariaDB-specific adapter to the SQL adapter, aliases Utopia\Database\Database as UtopiaDatabase, and initializes PDO using named parameters and SQL::getPDOAttributes(); setUp sequence adjusted. docker-compose.yml removes the adminer service and changes redis-cluster images to bitnamilegacy/redis-cluster:7.4.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The PR title "Chore update db" is related to the changeset but lacks clarity and specificity. While the pull request does include database-related changes (composer.json dependency update and Database test file refactoring), the actual scope extends significantly beyond a simple database update. The changes encompass test namespace reorganization across multiple files (Base.php, Redis.php, RedisCluster.php), adapter migration from MariaDB to SQL, Docker configuration updates, and dependency constraint loosening. The title "update db" is too generic to adequately convey what was actually changed or why, making it difficult for a teammate scanning the history to understand the primary scope of work. Consider revising the title to be more specific and descriptive of the actual changes. For example, a title like "Refactor test benchmarks and migrate to SQL adapter" or "Update database dependency and refactor test suite" would better capture the actual scope of work. The current title references a real aspect of the changes but is too vague to convey meaningful information about what the changeset accomplishes.
✅ 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%.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f517e66 and 3ee9320.

📒 Files selected for processing (1)
  • docker-compose.yml (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd59156 and ae497a7.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • composer.json (1 hunks)
  • tests/Abuse/Bench/Base.php (1 hunks)
  • tests/Abuse/Bench/Database.php (3 hunks)
  • tests/Abuse/Bench/Redis.php (1 hunks)
  • tests/Abuse/Bench/RedisCluster.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
tests/Abuse/Bench/RedisCluster.php (3)
src/Abuse/Abuse.php (1)
  • Abuse (5-56)
src/Abuse/Adapters/TimeLimit.php (1)
  • TimeLimit (8-105)
tests/Abuse/Bench/Base.php (1)
  • Base (12-32)
tests/Abuse/Bench/Redis.php (1)
tests/Abuse/Bench/Base.php (1)
  • Base (12-32)
tests/Abuse/Bench/Base.php (2)
src/Abuse/Abuse.php (1)
  • Abuse (5-56)
src/Abuse/Adapters/TimeLimit.php (1)
  • TimeLimit (8-105)
tests/Abuse/Bench/Database.php (2)
tests/Abuse/Bench/Base.php (1)
  • Base (12-32)
tests/Abuse/Base.php (1)
  • Base (9-99)
🪛 GitHub Actions: Linter
tests/Abuse/Bench/Database.php

[error] 1-1: Pint: no_unused_imports - Unused import detected. See PSR-12 in the lint results.

🔇 Additional comments (11)
tests/Abuse/Bench/Base.php (2)

9-10: LGTM: Necessary imports for namespace reorganization.

The new imports for Abuse and TimeLimit align with the namespace refactoring from Abuse\Bench to Utopia\Tests\Bench.


25-28: LGTM: Explicit global function qualification.

Using fully-qualified global function calls (\rand, \rtrim) is a defensive coding practice that improves clarity and avoids potential namespace conflicts.

tests/Abuse/Bench/RedisCluster.php (3)

3-3: LGTM: Namespace standardization.

The namespace change to Utopia\Tests\Bench aligns with the broader namespace reorganization across all benchmark files.


7-7: LGTM: Clean adapter aliasing.

Using RedisClusterAdapter as an alias improves readability and avoids confusion with the RedisCluster class name.


9-9: LGTM: Simplified class naming.

Renaming from RedisClusterBench to RedisCluster removes redundant "Bench" suffix while the namespace already indicates this is a benchmark file.

tests/Abuse/Bench/Redis.php (2)

3-3: LGTM: Namespace standardization.

The namespace change to Utopia\Tests\Bench is consistent with the broader refactoring across all benchmark files.


9-9: LGTM: Simplified class naming.

Renaming from RedisBench to Redis removes the redundant "Bench" suffix.

tests/Abuse/Bench/Database.php (3)

32-37: LGTM: Modern PDO constructor syntax.

Using named parameters improves readability and makes the PDO instantiation more explicit.


39-39: LGTM: Consistent alias usage.

Using UtopiaDatabase consistently with the import alias clarifies the distinction between the benchmark class and the library class.


12-13: Verify SQL adapter compatibility with MariaDB for this benchmark.

The adapters are external dependencies in the Utopia\Database package and cannot be verified through codebase inspection. Ensure that SQL::getPDOAttributes() returns appropriate PDO configuration for your MariaDB setup. The benchmark instantiates the MySQL adapter, so the getPDOAttributes() call must provide compatible options. Test the benchmark locally to confirm the migration works as expected.

composer.json (1)

25-25: Wildcard dependency constraint introduces breaking change risk.

Changing from "2.*" to "*" removes major version pinning for utopia-php/database, allowing any future major version to be installed. This confirmed to be a concern: version 3.0.0 was just released today (2025-10-20), and changing the constraint to a wildcard would allow this major version in routine dependency updates.

Before proceeding, verify that:

  • Code changes in this PR ensure compatibility with utopia-php/database 3.0.0 and its breaking changes, or
  • Pin the constraint to "2.*" or "^2.0" if 3.0.0 support is not intended.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae497a7 and f517e66.

📒 Files selected for processing (2)
  • docker-compose.yml (2 hunks)
  • tests/Abuse/Bench/Database.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/Abuse/Bench/Database.php (2)
tests/Abuse/Bench/Base.php (1)
  • Base (12-32)
tests/Abuse/Base.php (1)
  • Base (9-99)
🔇 Additional comments (6)
tests/Abuse/Bench/Database.php (5)

3-3: LGTM! Namespace refactoring aligns with test suite restructuring.

The namespace change from Abuse\Bench to Utopia\Tests\Bench is consistent with the broader test suite refactoring mentioned in the AI summary.


11-12: LGTM! Necessary imports for adapter changes.

The SQL adapter import supports the new SQL::getPDOAttributes() usage, and the UtopiaDatabase aliasing appropriately avoids naming conflicts with the test class.


15-15: LGTM! Class rename and final modifier are appropriate.

The class rename from DatabaseBench to Database aligns with the naming convention changes across benchmark tests, and the final modifier is a good practice for classes not intended for inheritance.


44-44: LGTM! Minor formatting improvement.

The updated formatting with the negation operator inside the parentheses improves code readability.


31-36: No issues found—PDO instantiation is correct.

The SQL::getPDOAttributes() method from Utopia Database provides appropriate PDO attributes for MySQL/MariaDB connections, including proper timeout, fetch mode, error handling, and prepared statement configuration. The code correctly uses the MySQL adapter with the mysql:// DSN, and the PHP 8.0+ named parameters follow best practices.

docker-compose.yml (1)

53-53: Confirm strategy for legacy Redis cluster image—frozen, no security updates.

Bitnami moved redis-cluster 7.4 to a legacy archive as part of repo reorganization and launch of paid Bitnami Secure Images; legacy images are frozen with no new versions, security fixes, or support. This is a known organizational change, not an error.

However, this creates a security risk: your deployment runs on an unmaintained image that will never receive patches. Before proceeding:

  1. Confirm this is intentional – ensure the team explicitly accepts the frozen image limitation
  2. Plan mitigation – either:
    • Pin and mirror the exact bitnami/redis-cluster:7.4 image into your private registry, or
    • Migrate to an actively maintained Redis cluster alternative
  3. Document the decision – add a comment in docker-compose.yml explaining the legacy image choice and accepted risk

Also applies to: lines 67, 75, 83

);

$db = new Database(new MySQL($pdo), new Cache(new NoCache()));
$db = new UtopiaDatabase(new MySQL($pdo), new Cache(new NoCache()));
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify MySQL adapter compatibility with existing database setup.

The database instantiation now explicitly uses the MySQL adapter. Please confirm that switching from the MariaDB adapter (if previously used) to the MySQL adapter doesn't affect functionality, especially given that the docker-compose.yml uses a MySQL 8 image.

Run the benchmark tests to ensure the adapter change doesn't introduce regressions:


🏁 Script executed:

#!/bin/bash
# Run the database benchmark tests

echo "=== Running Database benchmark tests ==="
vendor/bin/phpbench run tests/Abuse/Bench/Database.php --report=default

Length of output: 106


🏁 Script executed:

#!/bin/bash
# Check docker-compose.yml for database service configuration
echo "=== Docker Compose Database Configuration ==="
find . -name "docker-compose.yml" -o -name "docker-compose.yaml" | head -5 | xargs cat

echo -e "\n=== Looking for adapter-related code ==="
# Search for MySQL adapter usage patterns
rg -n "new MySQL|new MariaDB" --type=php -C2 | head -30

echo -e "\n=== Check for database adapter configuration ==="
rg -n "adapter|Adapter" tests/Abuse/Bench/Database.php -C3

echo -e "\n=== Examine the full database benchmark file ==="
cat tests/Abuse/Bench/Database.php

Length of output: 5047



🏁 Script executed:

#!/bin/bash
# Search for adapter implementations to compare getPDOAttributes()
echo "=== Searching for MariaDB adapter implementation ==="
rg -n "class MariaDB|getPDOAttributes" --type=php -B2 -A5 | grep -A 10 "class MariaDB"

echo -e "\n=== Searching for SQL adapter implementation ==="
rg -n "class SQL|getPDOAttributes" --type=php -B2 -A5 | grep -A 10 "class SQL"

echo -e "\n=== Check if MariaDB is imported in Bench/Database.php ==="
rg -n "MariaDB" tests/Abuse/Bench/Database.php

echo -e "\n=== Look for all uses of getPDOAttributes in tests ==="
rg -n "getPDOAttributes" --type=php -B1 -A1

Length of output: 407


🏁 Script executed:

#!/bin/bash
# Search for adapter implementations to compare getPDOAttributes()
echo "=== Searching for MariaDB adapter implementation ==="
rg -n "class MariaDB|getPDOAttributes" --type=php -B2 -A5 | head -50

echo -e "\n=== Searching for SQL adapter implementation ==="
rg -n "class SQL" --type=php -A10 | grep -A 10 "getPDOAttributes"

echo -e "\n=== Check if MariaDB is imported in Bench/Database.php ==="
rg -n "MariaDB" tests/Abuse/Bench/Database.php

echo -e "\n=== Look for all uses of getPDOAttributes in codebase ==="
rg -n "getPDOAttributes" --type=php -B2 -A2 | head -60

Length of output: 1059


🏁 Script executed:

#!/bin/bash
# Check composer.json for Utopia Database version
echo "=== Composer dependency info ==="
cat composer.json | grep -A 5 -B 5 "utopia/database" || grep -i database composer.json

echo -e "\n=== Check DatabaseTest.php for comparison ==="
cat tests/Abuse/DatabaseTest.php | head -50

echo -e "\n=== Search for any recent changes or patterns in test setup ==="
rg -n "SQL::getPDOAttributes|MariaDB::getPDOAttributes" --type=php -B3 -A3

Length of output: 2049


🏁 Script executed:

#!/bin/bash
# Search for all database initialization patterns
echo "=== All database initialization patterns in tests ==="
rg -n "new PDO.*mysql:|new MySQL|new MariaDB" --type=php -B1 -A1 | head -80

echo -e "\n=== Check if there are other benchmark or test files ==="
find tests -name "*.php" -type f | xargs grep -l "UtopiaDatabase\|new Database" | head -10

echo -e "\n=== Look for any base setup or factory ==="
cat tests/Abuse/Bench/Base.php 2>/dev/null || echo "Base.php not found in expected location"

Length of output: 1573


Update PDO attributes in DatabaseTest.php to match Bench/Database.php for consistency.

The change in Bench/Database.php uses SQL::getPDOAttributes() instead of MariaDB::getPdoAttributes() when connecting to MySQL 8. However, tests/Abuse/DatabaseTest.php (line 34) still uses MariaDB::getPdoAttributes() with the MySQL adapter, creating an inconsistency. Both test files should use the same PDO attributes source.

Update tests/Abuse/DatabaseTest.php line 34 to use SQL::getPDOAttributes() and import the SQL adapter class:

use Utopia\Database\Adapter\SQL;

Then change:

$pdo = new PDO("mysql:host={$dbHost};port={$dbPort};charset=utf8mb4", $dbUser, $dbPass, MariaDB::getPdoAttributes());

To:

$pdo = new PDO("mysql:host={$dbHost};port={$dbPort};charset=utf8mb4", $dbUser, $dbPass, SQL::getPDOAttributes());
🤖 Prompt for AI Agents
In tests/Abuse/DatabaseTest.php around line 34, update the MySQL PDO attributes
to match Bench/Database.php by importing the SQL adapter and switching the PDO
attributes call from MariaDB::getPdoAttributes() to SQL::getPDOAttributes(); add
the line to import Utopia\Database\Adapter\SQL at the top of the file and
replace the fourth argument passed to the PDO constructor accordingly so the
MySQL adapter uses SQL::getPDOAttributes().

@abnegate abnegate merged commit 611fa66 into main Oct 20, 2025
6 of 7 checks passed
@abnegate abnegate deleted the chore-update-db branch October 20, 2025 07:18
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.

2 participants