Skip to content
Open
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
10 changes: 8 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.6"
- "8.5"
- "8.4"
- "8.3"
Expand All @@ -34,7 +35,7 @@ jobs:
# for github/codeql-action/upload-sarif to upload SARIF results
security-events: write
container:
image: byjg/php:8.4-cli
image: byjg/php:8.5-cli
options: --user root --privileged

steps:
Expand All @@ -44,10 +45,15 @@ jobs:
- name: Composer
run: composer install

- name: Composer (psalm)

run: composer --working-dir=tools/psalm update --no-interaction


- name: Psalm
# Note: Ignoring error code 2, which just signals that some
# flaws were found, not that Psalm itself failed to run.
run: ./vendor/bin/psalm
run: ./tools/psalm/vendor/bin/psalm
--show-info=true
--report=psalm-results.sarif || [ $? = 2 ]

Expand Down
116 changes: 116 additions & 0 deletions CHANGELOG-7.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Changelog - Version 7.0

## Overview

Version 7.0 upgrades the underlying persistence stack to `byjg/micro-orm` 7.0 and
`byjg/anydataset-db` 7.0. The AuthUser public API is **unchanged**: `UsersService`,
`UsersRepository`, `UserPropertiesRepository`, models, enums and mapper interfaces keep the exact
same signatures as 6.x.

Since 6.0 the library was already wired exclusively through `DatabaseExecutor` — the API that
became mandatory in anydataset-db 7.0 — so no library code had to change beyond the dependency
constraints.

## Breaking Changes

### Dependencies

| Package | 6.x | 7.0 |
|---|---|---|
| `byjg/micro-orm` | `^6.0` | `^7.0` |
| `byjg/anydataset-db` (transitive) | `^6.0` | `^7.0` |

### Removed driver query methods (via anydataset-db 7.0)

The query methods deprecated on the drivers since anydataset-db 6.0 no longer exist
(`$dbDriver->execute()`, `getIterator()`, `getScalar()`, `executeAndGetId()`, `getAllFields()`).
If your application still calls them on the driver instance it passes to AuthUser, migrate to:

```php
<?php
use ByJG\AnyDataset\Db\DatabaseExecutor;

$executor = DatabaseExecutor::using($dbDriver);
$executor->execute($sql, $params);
```

The recommended wiring is unchanged and keeps working as-is:

```php
<?php
$dbDriver = Factory::getDbInstance('mysql://user:pass@host/db');
$executor = DatabaseExecutor::using($dbDriver);

$usersRepository = new UsersRepository($executor, UserModel::class);
$propertiesRepository = new UserPropertiesRepository($executor, UserPropertiesModel::class);
$service = new UsersService($usersRepository, $propertiesRepository, LoginField::Username);
```

### Observer system (via micro-orm 7.0)

micro-orm 7.0 removed the global `ORMSubject` singleton and rewired observers on top of the
`DatabaseExecutor` observer mechanism. AuthUser does not use observers internally, but if your
application registered observers on the AuthUser repositories, review the
[micro-orm 7.0 changelog](https://github.com/byjg/micro-orm/blob/master/CHANGELOG-7.0.md):
observers are now scoped per executor instead of global.

### Development dependencies

- PHPUnit: `^10.5|^11.5` → `^12.5`
- Psalm: `^5.9|^6.13` → `^6.13`

## Migration from 6.x

1. Update the composer constraint:

```json
{
"require": {
"byjg/authuser": "^7.0"
}
}
```

2. If your application already wires AuthUser through `DatabaseExecutor::using()` (the documented
pattern since 6.0), no code changes are required.
3. If you still call the removed query methods directly on the `DbDriverInterface` instance,
migrate those calls to `DatabaseExecutor` (see table in the
[anydataset-db 7.0 changelog](https://github.com/byjg/anydataset-db/blob/master/CHANGELOG-7.0.md)).

## Requirements

- PHP 8.3, 8.4, 8.5 and 8.6 are now supported: `"php": ">=8.3 <8.7"`.
The previous `<8.6` upper bound excluded PHP 8.6, since `<8.6` is exclusive.

### ByJG dependencies

- `byjg/cache-engine` is now `^7.0`.
- `byjg/jwt-wrapper` is now `^7.0`.
- `byjg/micro-orm` is now `^7.0`.

While 7.0 is unreleased these resolve to `7.0.x-dev` from each component's
`7.0` branch, via `minimum-stability: dev` with `prefer-stable: true`.

## Toolchain

- PHPUnit updated to `^12.5`.
- Psalm moved out of `require-dev` into its own manifest, `tools/psalm/composer.json`.

Psalm enumerates the PHP versions it supports and no published release lists
8.6. As a dev dependency it made `composer install` fail on the 8.6 build job
before any test ran. It now installs separately, only for the Psalm job.

`composer psalm` still works — it bootstraps the tool and runs it.

- PHPUnit 13 is deliberately **not** used. It requires PHP `>=8.4.1`, breaking the
8.3 floor, and needs `sebastian/diff ^9.0`, which stable Psalm 6.16.1 rejects —
a combination that silently resolves Psalm to an unreleased `6.x-dev` branch.

## Continuous Integration

- The build matrix now includes PHP 8.6.
- The Psalm job runs on PHP 8.5 and installs Psalm from `tools/psalm`.

## Housekeeping

- `phpunit.xml.dist` renamed to `phpunit.xml`.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,5 @@ Because this project uses PHP Session you need to run the unit test the followin

This project is licensed under the MIT License - see the [LICENSE](https://github.com/byjg/php-authuser/blob/master/LICENSE) file for details.

## Dependencies

```mermaid
flowchart TD
byjg/authuser --> byjg/micro-orm
byjg/authuser --> byjg/cache-engine
byjg/authuser --> byjg/jwt-wrapper
```

----
[Open source ByJG](http://opensource.byjg.com)
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.3 <8.6",
"byjg/micro-orm": "^6.0",
"byjg/cache-engine": "^6.0",
"byjg/jwt-wrapper": "^6.0"
"php": ">=8.3 <8.7",
"byjg/micro-orm": "^7.0",
"byjg/cache-engine": "^7.0",
"byjg/jwt-wrapper": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^10.5|^11.5",
"vimeo/psalm": "^5.9|^6.13"
"phpunit/phpunit": "^12.5"
},
"scripts": {
"test": "vendor/bin/phpunit",
"psalm": "vendor/bin/psalm --threads=1"
"psalm": [
"@composer --working-dir=tools/psalm update --no-interaction",
"tools/psalm/vendor/bin/psalm --threads=1"
]
},
"license": "MIT"
}
File renamed without changes.
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cacheDirectory="/tmp/psalm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
xsi:schemaLocation="https://getpsalm.org/schema/config tools/psalm/vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
Expand Down
6 changes: 3 additions & 3 deletions tests/PasswordMd5MapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class PasswordMd5MapperTest extends TestCase
public function setUp(): void
{
$this->db = Factory::getDbInstance(self::CONNECTION_STRING);
$this->db->execute('create table users (
$executor = DatabaseExecutor::using($this->db);
$executor->execute('create table users (
userid integer primary key autoincrement,
name varchar(45),
email varchar(200),
Expand All @@ -37,15 +38,14 @@ public function setUp(): void
role varchar(20));'
);

$this->db->execute('create table users_property (
$executor->execute('create table users_property (
id integer primary key autoincrement,
userid integer,
name varchar(45),
value varchar(45));'
);

// Create repositories and service with custom MD5 password mapper via UserModelMd5
$executor = DatabaseExecutor::using($this->db);
$usersRepository = new UsersRepository($executor, UserModelMd5::class);
$propertiesRepository = new UserPropertiesRepository($executor, UserPropertiesModel::class);
$this->service = new UsersService(
Expand Down
8 changes: 4 additions & 4 deletions tests/UsersDBDataset2ByUserNameTestUsersBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ public function __setUp($loginField)
$this->prefix = "";
$this->loginField = $loginField;

$this->db = Factory::getDbRelationalInstance(self::CONNECTION_STRING);
$this->db->execute('create table mytable (
$this->db = Factory::getDbInstance(self::CONNECTION_STRING);
$executor = DatabaseExecutor::using($this->db);
$executor->execute('create table mytable (
myuserid integer primary key autoincrement,
myname varchar(45),
myemail varchar(200),
Expand All @@ -35,14 +36,13 @@ public function __setUp($loginField)
myrole varchar(20));'
);

$this->db->execute('create table theirproperty (
$executor->execute('create table theirproperty (
theirid integer primary key autoincrement,
theiruserid integer,
theirname varchar(45),
theirvalue varchar(45));'
);

$executor = DatabaseExecutor::using($this->db);
$usersRepository = new UsersRepository($executor, CustomUserModel::class);
$propertiesRepository = new UserPropertiesRepository($executor, CustomUserPropertiesModel::class);
$this->object = new UsersService(
Expand Down
6 changes: 3 additions & 3 deletions tests/UsersDBDatasetByUsernameTestUsersBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function __setUp($loginField)
$this->loginField = $loginField;

$this->db = Factory::getDbInstance(self::CONNECTION_STRING);
$this->db->execute('create table users (
$executor = DatabaseExecutor::using($this->db);
$executor->execute('create table users (
userid integer primary key autoincrement,
name varchar(45),
email varchar(200),
Expand All @@ -38,14 +39,13 @@ public function __setUp($loginField)
role varchar(20));'
);

$this->db->execute('create table users_property (
$executor->execute('create table users_property (
id integer primary key autoincrement,
userid integer,
name varchar(45),
value varchar(45));'
);

$executor = DatabaseExecutor::using($this->db);
$usersRepository = new UsersRepository($executor, UserModel::class);
$propertiesRepository = new UserPropertiesRepository($executor, UserPropertiesModel::class);
$this->object = new UsersService(
Expand Down
6 changes: 3 additions & 3 deletions tests/UsersDBDatasetDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function __setUp($loginField)
$this->loginField = $loginField;

$this->db = Factory::getDbInstance(self::CONNECTION_STRING);
$this->db->execute('create table mytable (
$executor = DatabaseExecutor::using($this->db);
$executor->execute('create table mytable (
myuserid integer primary key autoincrement,
myname varchar(45),
myemail varchar(200),
Expand All @@ -51,14 +52,13 @@ public function __setUp($loginField)
myrole varchar(20));'
);

$this->db->execute('create table theirproperty (
$executor->execute('create table theirproperty (
theirid integer primary key autoincrement,
theiruserid integer,
theirname varchar(45),
theirvalue varchar(45));'
);

$executor = DatabaseExecutor::using($this->db);
$usersRepository = new UsersRepository($executor, MyUserModel::class);
$propertiesRepository = new UserPropertiesRepository($executor, MyUserPropertiesModel::class);
$this->object = new UsersService(
Expand Down
5 changes: 5 additions & 0 deletions tools/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"vimeo/psalm": "^6.16"
}
}
Loading