Commit Graph

143 Commits

Author SHA1 Message Date
Damodar Lohani ce31a4f336 feat!: rename User::ROLE_APPS to ROLE_KEYS and isApp() to isKey() 2026-05-24 02:20:47 +00:00
Matej Bačo 152b45087e Fix more tests 2026-05-11 17:01:00 +02:00
ArnabChatterjee20k 737c85822d multi line comment 2026-05-04 12:46:44 +05:30
ArnabChatterjee20k 1fc3a8803c multiline comment 2026-05-04 12:45:32 +05:30
ArnabChatterjee20k f5a7cfd2ea fix: resolve query syntax errors and improve error handling in Request class 2026-05-04 12:22:48 +05:30
Damodar Lohani 30a511692b test: add unit coverage for Request::getHeader non-string coercion
Refs CLO-4280
2026-04-28 04:15:00 +00:00
Chirag Aggarwal d2230f8fe7 chore: bump PHPStan to level 4 and fix all new errors
Raises `phpstan.neon` level from 3 to 4 and fixes the 549 new errors
that level 4 surfaces across 157 files. Fixes are root-cause — no
`@phpstan-ignore`, no `@var` casts, no baseline entries, no widened
types. A handful of latent bugs were fixed along the way:

- `app/controllers/general.php`: path-traversal guard was negating
  `\substr(...)` before the strict comparison (`!\substr(...) === $base`
  was always `false === $base`). Rewritten as `\substr(...) !== $base`.
- `src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php`
  and `.../TablesDB/Logs/XList.php`: were importing the raw Matomo
  `DeviceDetector` (whose `getDevice()` returns `?int`) but treating the
  result as an array with `deviceName/deviceBrand/deviceModel` keys.
  Swapped to `Appwrite\Detector\Detector`, matching the wrapper already
  used a few lines below for `$os`/`$client`.
- `src/Appwrite/Platform/Modules/Functions/Workers/Builds.php`: a match
  key was checking `$resourceKey === 'functions'` when `$resourceKey`
  is `'functionId'|'siteId'` — always false. Switched to the intended
  `$resource->getCollection() === 'functions'` check.
- `src/Appwrite/OpenSSL/OpenSSL.php`: `encrypt()` return type tightened
  to `string|false` to match `openssl_encrypt`; this lets callers'
  `=== false` error handling remain meaningful.
- `app/controllers/api/messaging.php`: removed a dead
  `array_key_exists('from', [])` branch in the Msg91 provider (empty
  array literal; branch was unreachable).

Large cleanup categories across the 549 fixes:
- Removed redundant `?? default` on array offsets and expressions that
  PHPStan now knows are non-nullable.
- Removed unreachable statements (mostly `return;` after `throw` or
  `markTestSkipped()`).
- Removed redundant `is_array`/`is_string`/`is_bool`/`instanceof` checks
  on already-narrowed types.
- Added `default =>` arms (or throwing arms) to non-exhaustive matches
  on `string`/`mixed` input.
- Removed dead `$document === false` branches where method return types
  were tightened to non-nullable `Document`.
- Removed unused properties (`$version` on Etsy/Zoom OAuth2, `$paths` on
  Installer State, `$source` on MigrationsWorker, `$account2` on two
  GraphQL auth tests), unused traits (`ApiVectorsDB`, `DatabaseFixture`),
  and an unused `cleanupStaleExecutions` task method.
- Replaced `assertTrue(true)` and redundant `assertIsArray`/`assertIsString`/
  `assertNotNull` assertions with `addToAssertionCount(1)` or
  `assertNotEmpty` where the runtime type was already known.
2026-04-19 17:31:20 +05:30
Chirag Aggarwal b8eb0810c2 Make response sensitive mode instance-scoped 2026-04-06 10:24:32 +05:30
Chirag Aggarwal cb74a5756a Remove request and response static state 2026-04-06 10:20:18 +05:30
Chirag Aggarwal 18ed6a9c59 Fix more PHPStan static access issues 2026-03-31 22:04:37 +05:30
Claude 7aff75ae1c refactor: convert User::isApp() and User::isPrivileged() from static to instance methods
All call sites now use $user->isApp() and $user->isPrivileged() instance
syntax instead of static User::isApp() / $user::isPrivileged() calls.
Added setUser() to Request class for consistency with Response.

https://claude.ai/code/session_01JLPDurUgyj7qViA8JqQFTH
2026-03-26 02:47:56 +00:00
Jake Barnby 91e252382b (test): add strict type assertions and list coverage for V21 $sequence filter 2026-03-20 17:33:15 +13:00
Jake Barnby 827dd2d039 fix: preserve integer type for $sequence and handle nested relationship casting
- Document/Row model filters now preserve int type for $sequence instead of always casting to string
- V21 response filter recursively casts $sequence on nested relationship documents
- Added unit tests for nested document/row $sequence casting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 16:36:04 +13:00
Jake Barnby c155c88a31 Fix stan 2026-03-20 15:37:23 +13:00
Jake Barnby 9235a4cc15 test: add V21 request and response filter unit tests 2026-03-20 13:08:27 +13:00
Jake Barnby 8a6ddeef30 Merge branch '1.8.x' into feat-mongodb 2026-02-20 01:33:02 +13:00
Hemachandar 14e79f34db Populate project-specific roles (#11209)
* Populate project-specific roles

* better comments

* simplify

* privileged user

* update permissions

* feedback

* lint

* only read + cleanup

* fix role length

* scopes

* not api-key

* cl-ignore group

* rename

* ciIgnore

* base scope

* change base scope

* fix projects

* copilot suggestion
2026-02-19 16:48:39 +05:30
Jake Barnby 64a368ba3d Merge remote-tracking branch 'origin/feat-db-tests' into feat-mongodb
# Conflicts:
#	.github/workflows/tests.yml
#	src/Appwrite/Utopia/Response.php
#	src/Appwrite/Utopia/Response/Model/AttributeList.php
#	tests/e2e/Client.php
#	tests/e2e/Scopes/ProjectCustom.php
#	tests/e2e/Services/Databases/DatabasesBase.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/Transactions/TransactionsBase.php
#	tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php
#	tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php
#	tests/e2e/Services/Messaging/MessagingBase.php
#	tests/e2e/Services/Sites/SitesBase.php
#	tests/e2e/Services/Sites/SitesCustomServerTest.php
2026-02-18 03:27:23 +13:00
Jake Barnby 5590f0bcd0 Merge remote-tracking branch 'origin/1.8.x' into feat-mongodb
# Conflicts:
#	.env
#	.github/workflows/tests.yml
#	app/controllers/api/projects.php
#	app/controllers/api/teams.php
#	app/init/registers.php
#	app/views/install/compose.phtml
#	composer.json
#	composer.lock
#	docker-compose.yml
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php
#	src/Appwrite/Platform/Tasks/Install.php
#	src/Appwrite/Platform/Tasks/Upgrade.php
#	tests/e2e/Services/Databases/Legacy/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
2026-02-12 23:35:21 +13:00
Jake Barnby 7d5f6c9bf3 Merge remote-tracking branch 'origin/1.8.x' into feat-db-tests
# Conflicts:
#	.github/workflows/tests.yml
#	composer.lock
#	tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
#	tests/e2e/Services/Teams/TeamsCustomClientTest.php
2026-02-12 12:34:42 +13:00
Chirag Aggarwal 2d05d608f4 Upgrade utopia-php dependencies and fix namespace changes
- Upgrade utopia-php/cli from 0.15 to 0.22
- Upgrade utopia-php/analytics from 0.10 to 0.15
- Upgrade utopia-php/orchestration from 0.9 to 0.19
- Use dev branches for utopia-php/framework and utopia-php/platform
- Remove utopia-php/swoole dependency (merged into framework)
- Migrate Utopia\CLI\Console to Utopia\Console across all files
- Migrate Utopia\Http to Utopia\Http\Http namespace
- Migrate Utopia\Swoole\Files to Utopia\Http\Files (now instance-based)
- Convert static CLI::setResource() calls to instance-based Dependency API
- Fix StatsResources task named parameter mismatch
2026-02-10 10:34:24 +05:30
Jake Barnby c8d2cc090e Merge remote-tracking branch 'origin/1.8.x' into feat-db-tests
# Conflicts:
#	tests/e2e/Services/Databases/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
2026-02-06 01:29:44 +13:00
Jake Barnby e21614088f fix: Address CodeRabbit review comments
- Fix OR precheck bug: skip attribute existence check when OR conditions
  exist, since OR can match with partial attributes present
- Remove dead code in app/realtime.php (unused $names and $channels variables)
- Add tests for OR queries with missing attributes in one branch

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 22:24:26 +13:00
Jake Barnby 18125156d2 fix: Update compileAndFilter return type to nullable array
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 22:14:41 +13:00
Jake Barnby 765d334674 fix: Return null instead of empty array for non-matching queries
RuntimeQuery::filter() now returns null when the query doesn't match,
instead of an empty array. This distinguishes between "no match" and
"match with empty payload", fixing the issue where subscriptions with
empty payloads weren't being delivered.

Updated Realtime::getSubscribers() to check for null instead of using
!empty(), and updated all tests to expect null for non-matches.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 22:08:43 +13:00
Jake Barnby 3e31094e1e fix: Fix unit test failures for RuntimeQuery and Messaging tests
- Add missing isSelectAll() method to RuntimeQuery class
- Update RuntimeQueryTest to use compile() before filter() since filter()
  expects pre-compiled query arrays, not Query objects
- Remove incorrect break statement in Realtime::getSubscribers() that was
  stopping iteration after the first matching channel, causing subscribers
  to not be found for subsequent channels
- Use local variable $subscriptionsByChannel to avoid unused variable warning

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 21:57:00 +13:00
Jake Barnby e70739a3c0 Merge remote-tracking branch 'origin/1.8.x' into feat-mongodb
# Conflicts:
#	Dockerfile
#	app/controllers/api/account.php
#	app/controllers/api/avatars.php
#	app/controllers/api/console.php
#	app/controllers/api/projects.php
#	app/controllers/api/storage.php
#	app/controllers/api/teams.php
#	app/http.php
#	app/init/database/filters.php
#	app/init/registers.php
#	app/init/resources.php
#	app/views/install/compose.phtml
#	composer.json
#	composer.lock
#	docker-compose.yml
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Integer/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Integer/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Bulk/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Upsert.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Update.php
#	src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Update.php
#	src/Appwrite/Platform/Modules/Functions/Http/Deployments/XList.php
#	src/Appwrite/Platform/Tasks/Install.php
#	tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
2026-02-05 01:01:03 +13:00
Jake Barnby d4694ff8af Merge remote-tracking branch 'origin/1.8.x' into feat-db-tests
# Conflicts:
#	composer.json
#	composer.lock
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
#	tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
#	tests/e2e/Services/Realtime/RealtimeCustomClientTest.php
2026-02-04 19:49:09 +13:00
ArnabChatterjee20k 6e576b5140 added realtime query new channel and channel wise filters 2026-02-02 19:45:21 +05:30
Jake Barnby 8335e43eaa Merge branch '1.8.x' into feat-db-tests 2026-01-19 18:34:35 +13:00
ArnabChatterjee20k b1fab79dc4 updated query logic in array to be of and format 2026-01-16 19:06:55 +05:30
ArnabChatterjee20k da871635d9 Fix namespace import for RuntimeQuery class and update test file accordingly 2026-01-16 16:16:03 +05:30
ArnabChatterjee20k b2486fcb6c Merge remote-tracking branch 'upstream/1.8.x' into dat-969 2026-01-16 15:47:25 +05:30
Jake Barnby 714b8d7ea6 Migrate to PHPUnit 11 2026-01-15 16:14:53 +13:00
Jake Barnby 2cfb5ecfd9 Reapply "Merge pull request #11130 from appwrite/feat-auth-instance"
This reverts commit 38687bc24e.
2026-01-15 04:08:00 +13:00
Jake Barnby 38687bc24e Revert "Merge pull request #11130 from appwrite/feat-auth-instance"
This reverts commit c12cad80bb, reversing
changes made to 2a17429226.

# Conflicts:
#	composer.lock
2026-01-15 03:48:42 +13:00
Jake Barnby 5c915ef92f Reapply "Merge pull request #11099 from appwrite/feat-auth-instance"
This reverts commit 321fc8ee70.
2026-01-14 19:07:49 +13:00
Jake Barnby 321fc8ee70 Revert "Merge pull request #11099 from appwrite/feat-auth-instance"
This reverts commit a4734a5de7, reversing
changes made to 15922fb88c.

# Conflicts:
#	composer.lock
2026-01-14 02:37:17 +13:00
Jake Barnby 7573ee75a2 Use authorization instance 2026-01-07 20:04:28 +13:00
ArnabChatterjee20k 874e5f61f0 Merge remote-tracking branch 'upstream/1.8.x' into dat-969 2025-12-24 19:01:13 +05:30
ArnabChatterjee20k 39cf207df9 re 2025-12-24 18:57:58 +05:30
Jake Barnby dc85d44647 Revert "Refactor auth single instance" 2025-12-20 02:54:50 +13:00
Jake Barnby a8cf0a6176 Merge remote-tracking branch 'origin/1.8.x' into feat-mongodb
# Conflicts:
#	app/controllers/api/teams.php
#	app/init/resources.php
#	composer.lock
#	tests/e2e/Services/Databases/Legacy/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
2025-12-10 20:12:27 +13:00
shimon 5b3659af7c Remove unused Auth import in storage controller and fix formatting in UserTest class 2025-11-28 16:11:48 +02:00
shimon 67311fe5d6 Refactor: Update role retrieval to use authorization object in multiple files 2025-11-27 18:56:33 +02:00
Damodar Lohani 12c27edaf9 Fix user test 2025-11-05 05:23:32 +00:00
Damodar Lohani 918ad4a545 remove auth test and add user test 2025-11-04 07:41:42 +00:00
Jake Barnby 1e60a01a69 Use db length for project ID 2025-10-21 15:31:46 +13:00
Jake Barnby c3d4cf947e Fix unit test 2025-10-21 14:24:32 +13:00
Jake Barnby 0d35af8cfa Fix tests 2025-10-21 14:24:26 +13:00