Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"ext-pdo": "*",
"ext-curl": "*",
"ext-redis": "*",
"utopia-php/database": "3.*.*",
"appwrite/appwrite": "19.*.*"
"utopia-php/database": "4.*",
"appwrite/appwrite": "19.*"
Comment on lines +25 to +26
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for Database namespace usage patterns
echo "=== Searching for Database namespace usage ==="
rg "use Utopia\\\\Database" --type php -n

echo ""
echo "=== Searching for Database class instantiation ==="
rg "Database\b" --type php -n | head -20

echo ""
echo "=== Checking for specific database operations ==="
rg "(createDocument|updateDocument|deleteDocument|find|findOne|getDocument)" --type php -n | head -20

Repository: utopia-php/abuse

Length of output: 4819


🌐 Web query:

utopia-php/database v4 breaking changes migration

💡 Result:

Quick notes to start a v3 -> v4 migration for utopia-php/database:

  • Minimum PHP now >= 8.1 (composer metadata). [1]
  • See the project source and releases for the full v4 changelog / breaking-change list on the repository (tags/releases). I can extract the exact breaking changes and a step-by-step migration checklist if you want—should I fetch the repo's v4 changelog and PRs now? [2]

Sources:
[1] Packagist: utopia-php/database (package details, versions & requirements).
[2] GitHub: utopia-php/database (repository / releases).


🌐 Web query:

utopia-php/database v4.0.0 release notes changelog

💡 Result:

Do you want a brief summary of the v4.0.0 changes or the full changelog text and a link to the release on GitHub/Packagist?


🏁 Script executed:

#!/bin/bash
# Check if there's a CHANGELOG or MIGRATION guide in the repo
echo "=== Looking for changelog or migration docs ==="
fd "CHANGELOG|MIGRATION|UPGRADE|RELEASE" . --type f -i | head -20

Repository: utopia-php/abuse

Length of output: 107


🌐 Web query:

site:github.com utopia-php/database v4 breaking changes API migration

💡 Result:

I couldn't find a dedicated "v4 migration guide" inside the utopia-php/database GitHub repo, but these sources are relevant:

  • Package page (shows current v4.x releases and README). [1]
  • Appwrite community reports referencing breaking/migration issues tied to utopia-php/database during Appwrite upgrades (useful for practical migration problems you may hit). [2][3]

If you want, I can:

  • Open the utopia-php/database GitHub repo and search its CHANGELOG.md / releases for explicit v4 breaking-change notes; or
  • Scan the repo for files mentioning "migration", "upgrade", "breaking", or "CHANGELOG" and summarize the API changes.

Which would you like me to do?

Sources:
[1] Packagist — utopia-php/database (package page, versions/README). (packagist.org)
[2] Appwrite forum thread: "Build broken" referencing Utopia Database errors. (appwrite.io)
[3] Appwrite forum thread: "Fail migrate 1.6.2 to 1.7.1" showing Database API type errors during migration. (appwrite.io)

Citations:


🌐 Web query:

utopia-php/database releases v4.0.0 what's new breaking changes

💡 Result:

Do you want me to fetch the official v4.0.0 release notes and breaking-change list from the utopia-php/database GitHub (or Packagist) and summarize them?


🌐 Web query:

"utopia-php/database" "v4" "breaking change" OR "migration" API changes

💡 Result:

I couldn't find a published v4 migration / breaking-change guide for utopia-php/database. The package does have v4.x releases on Packagist (latest listed v4.3.0), but I couldn't locate a changelog or migration notes for v4 on the package pages I searched. Sources: [Packagist — utopia-php/database]. [Packagist — utopia-php/framework].

Do you want me to (1) fetch the repository releases/changelog on GitHub (please confirm the exact repo URL if different), or (2) scan the v4.x tag/commits for API changes and list breaking changes?


🏁 Script executed:

#!/bin/bash
# Check the composer.lock or composer files to see current installed versions
echo "=== Checking composer configuration ==="
head -50 composer.json | grep -A 5 -B 5 "utopia-php/database\|appwrite/appwrite"

Repository: utopia-php/abuse

Length of output: 416


🏁 Script executed:

#!/bin/bash
# Check if the change is already committed or proposed
echo "=== Checking composer.json git status ==="
git status composer.json 2>/dev/null || echo "Not a git repo"

echo ""
echo "=== Checking recent git history for composer.json changes ==="
git log --oneline -10 composer.json 2>/dev/null || echo "Git history unavailable"

echo ""
echo "=== Checking PHP version requirement against v4 needs ==="
echo "Current composer.json PHP requirement:"
grep '"php"' composer.json
echo ""
echo "v4 database likely requires PHP 8.1+, current constraint is PHP 8.0+"

Repository: utopia-php/abuse

Length of output: 505


Update PHP version constraint to >= 8.1 to match utopia-php/database v4 requirement.

The upgrade to utopia-php/database v4 introduces a PHP >= 8.1 requirement, but the library currently declares php: ">=8.0" in composer.json. Update the PHP constraint to ">=8.1" to ensure compatibility with the database package v4.

The appwrite/appwrite change from 19.*.* to 19.* is just constraint format normalization with no functional impact.

🤖 Prompt for AI Agents
In `@composer.json` around lines 25 - 26, Update the PHP platform constraint in
composer.json from ">=8.0" to ">=8.1" to satisfy the utopia-php/database v4
requirement; locate the "php" entry in composer.json's "require" section and
modify its version string accordingly, then run composer validate (and composer
update if needed) to ensure dependencies resolve against PHP >=8.1.

},
"require-dev": {
"phpunit/phpunit": "9.*",
Expand Down
77 changes: 38 additions & 39 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions src/Abuse/Adapters/TimeLimit/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Utopia\Database\Exception\Duplicate;
use Utopia\Database\Exception\Structure;
use Utopia\Database\Query;
use Utopia\Database\Validator\Authorization;
use Utopia\Exception;

class Database extends TimeLimit
Expand Down Expand Up @@ -139,7 +138,7 @@ protected function count(string $key, int $timestamp): int
$timestamp = $this->toDateTime($timestamp);

/** @var array<Document> $result */
$result = Authorization::skip(function () use ($key, $timestamp) {
$result = $this->db->getAuthorization()->skip(function () use ($key, $timestamp) {
return $this->db->find(self::COLLECTION, [
Query::equal('key', [$key]),
Query::equal('time', [$timestamp]),
Expand Down Expand Up @@ -172,7 +171,7 @@ protected function hit(string $key, int $timestamp): void
}

$timestamp = $this->toDateTime($timestamp);
Authorization::skip(function () use ($timestamp, $key) {
$this->db->getAuthorization()->skip(function () use ($timestamp, $key) {
$data = $this->db->findOne(self::COLLECTION, [
Query::equal('key', [$key]),
Query::equal('time', [$timestamp]),
Expand Down Expand Up @@ -226,7 +225,7 @@ protected function hit(string $key, int $timestamp): void
protected function set(string $key, int $timestamp, int $value): void
{
$timestamp = $this->toDateTime($timestamp);
Authorization::skip(function () use ($timestamp, $key, $value) {
$this->db->getAuthorization()->skip(function () use ($timestamp, $key, $value) {
$data = $this->db->findOne(self::COLLECTION, [
Query::equal('key', [$key]),
Query::equal('time', [$timestamp]),
Expand Down Expand Up @@ -284,7 +283,7 @@ protected function set(string $key, int $timestamp, int $value): void
public function getLogs(?int $offset = null, ?int $limit = 25): array
{
/** @var array<Document> $results */
$results = Authorization::skip(function () use ($offset, $limit) {
$results = $this->db->getAuthorization()->skip(function () use ($offset, $limit) {
$queries = [];
$queries[] = Query::orderDesc('');

Expand Down Expand Up @@ -312,7 +311,7 @@ public function getLogs(?int $offset = null, ?int $limit = 25): array
public function cleanup(int $timestamp): bool
{
$timestamp = $this->toDateTime($timestamp);
Authorization::skip(function () use ($timestamp) {
$this->db->getAuthorization()->skip(function () use ($timestamp) {
do {
$documents = $this->db->find(self::COLLECTION, [
Query::lessThan('time', $timestamp),
Expand Down