Commit Graph

25 Commits

Author SHA1 Message Date
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
Damodar Lohani d831b93934 Allow deleting user account with active memberships
Instead of blocking account deletion when the user has confirmed team
memberships, handle memberships gracefully during deletion:

- Sole owner + sole member: delete the team and queue project cleanup
- Sole owner + other members: transfer ownership to the next member
- Non-owner / multiple owners: no special handling needed (worker cleans up)

Also update the Deletes worker to transfer the team's primary user
reference when removing a deleted user's memberships.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 01:43:05 +00:00
Jake Barnby bada1a7c05 Timing updates 2026-02-24 14:00:07 +13:00
Jake Barnby 879a599bed Fix parallel cases 2026-01-11 02:33:20 +13:00
Darshan ee3b2d75ae add: missing test at console level. 2026-01-02 17:01:03 +05:30
Hemachandar f9542e2be2 Update base template for session alert email 2025-10-31 17:52:47 +05:30
Jake Barnby ddde13a78f Revert "Merge pull request #10468 from appwrite/feat-apps-module-dl"
This reverts commit 9dd1939d1f, reversing
changes made to 8dfdfcb522.

# Conflicts:
#	app/config/collections/common.php
#	app/controllers/api/users.php
#	app/init/resources.php
#	composer.lock
2025-10-21 14:59:30 +13:00
Eldad Fux afb40218d7 Fixed tests 2025-03-18 16:12:13 +01:00
Torsten Dittmann 0a1d572c72 chore: run formatter 2024-03-06 18:34:21 +01:00
Jake Barnby 942847cf3a Merge remote-tracking branch 'origin/main' into 1.5.x
# Conflicts:
#	app/config/collections.php
#	app/config/errors.php
#	app/config/specs/open-api3-latest-client.json
#	app/config/specs/open-api3-latest-console.json
#	app/config/specs/open-api3-latest-server.json
#	app/config/specs/swagger2-latest-client.json
#	app/config/specs/swagger2-latest-console.json
#	app/config/specs/swagger2-latest-server.json
#	app/controllers/api/account.php
#	app/controllers/api/teams.php
#	app/controllers/api/users.php
#	app/controllers/shared/api.php
#	app/init.php
#	app/worker.php
#	composer.json
#	composer.lock
#	docker-compose.yml
#	src/Appwrite/Extend/Exception.php
#	src/Appwrite/Platform/Services/Tasks.php
#	src/Appwrite/Platform/Tasks/Maintenance.php
#	src/Appwrite/Platform/Workers/Certificates.php
#	src/Appwrite/Platform/Workers/Deletes.php
#	src/Appwrite/Platform/Workers/Messaging.php
#	src/Appwrite/Platform/Workers/Usage.php
#	src/Appwrite/Platform/Workers/UsageHook.php
#	src/Appwrite/Specification/Format/OpenAPI3.php
#	src/Appwrite/Specification/Format/Swagger2.php
#	tests/e2e/Services/Account/AccountConsoleClientTest.php
2024-02-22 01:29:28 +13:00
Damodar Lohani 359b3326d9 remove unused import 2024-01-28 03:03:20 +00:00
Damodar Lohani 7a94bd143c update account delete test 2024-01-28 03:02:44 +00:00
loks0n 7109e85711 test: seperate client and server tests 2023-10-26 09:43:15 +01:00
Jake Barnby 3d0ae4b9d9 Remove invites codes 2023-08-30 00:31:38 -04:00
Matej Bačo 293e44e91e Introduce SMTP ping timeout 2023-08-24 13:04:49 +02:00
Steven Nguyen aa3c2faed9 Merge tag '1.3.8' into cloud-1.3.x-2 2023-08-04 13:55:07 -07:00
Matej Bačo c01fcb130c Merge branch 'feat-db-pools-master' into feat-db-pools-sync 2023-03-14 12:58:54 +01:00
shimon 8d795ef483 addressing comments 2023-02-05 22:39:41 +02:00
shimon 5850a454e0 addressing comments 2023-02-05 22:07:46 +02:00
Christy Jacob 222421d8f3 feat: update account codes 2023-01-19 17:41:15 +05:30
Christy Jacob 4142ffdb70 feat: update account codes 2023-01-19 17:26:41 +05:30
Christy Jacob a2dfd692f1 feat: add tests 2023-01-11 18:09:56 +05:30
Christy Jacob d7104d9cd6 feat: add tests 2023-01-11 17:54:37 +05:30
Everly Precia Suresh 19300ccdd7 format files in app, src, tests 2022-05-23 14:54:50 +00:00
Eldad Fux 5d33721e60 Updated tests structure 2020-01-12 08:35:37 +02:00