| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\User\Options; |
| 4 | |
| 5 | use MediaWiki\User\UserIdentity; |
| 6 | |
| 7 | /** |
| 8 | * @since 1.43 |
| 9 | * @stable to implement |
| 10 | */ |
| 11 | interface UserOptionsStore { |
| 12 | /** |
| 13 | * Fetch all options for a given user from the store. |
| 14 | * |
| 15 | * Note that OptionsStore does not handle fallback to default. Options are |
| 16 | * either present or absent. |
| 17 | * |
| 18 | * @param UserIdentity $user A user with a non-zero ID |
| 19 | * @param int $recency a bit field composed of READ_XXX flags |
| 20 | * @return array<string,string> |
| 21 | */ |
| 22 | public function fetch( UserIdentity $user, int $recency ); |
| 23 | |
| 24 | /** |
| 25 | * Process a batch of option updates. |
| 26 | * |
| 27 | * The store may assume that fetch() was previously called with a recency |
| 28 | * sufficient to provide reference values for a differential update. It is |
| 29 | * the caller's responsibility to manage recency. |
| 30 | * |
| 31 | * Note that OptionsStore does not have a concept of defaults. The store is |
| 32 | * not required to check whether the value matches the default. |
| 33 | * |
| 34 | * @param UserIdentity $user A user with a non-zero ID |
| 35 | * @param array<string,string|null> $updates A map of option names to new |
| 36 | * values. If the value is null, the key should be deleted from the store |
| 37 | * and subsequently not returned from fetch(). Absent keys should be left |
| 38 | * unchanged. |
| 39 | * @return bool Whether any change was made |
| 40 | */ |
| 41 | public function store( UserIdentity $user, array $updates ); |
| 42 | } |