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
78 changes: 78 additions & 0 deletions CHANGELOG-7.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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)).
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"prefer-stable": true,
"require": {
"php": ">=8.3 <8.6",
"byjg/micro-orm": "^6.0",
"byjg/cache-engine": "^6.0",
"byjg/micro-orm": "^7.0",
"byjg/cache-engine": "^7.0",
"byjg/jwt-wrapper": "^6.0"
},
"require-dev": {
"phpunit/phpunit": "^10.5|^11.5",
"vimeo/psalm": "^5.9|^6.13"
"phpunit/phpunit": "^12.5",
"vimeo/psalm": "^6.13"
},
"scripts": {
"test": "vendor/bin/phpunit",
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
Loading