Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/changelogs/v4.7.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Release Date: Unreleased

## Bugs Fixed

- **Cache:** Fixed a bug where `PredisHandler::increment()` and `PredisHandler::decrement()` updated the unused `'data'` hash field instead of `'__ci_value'`, causing `get()` to return stale values for existing counters.
- **CORS:** Fixed a bug where `Cors::hasResponseHeaders()` matched header substrings via `str_contains()`, causing false positives when existing exposed headers shared a prefix with configured exposed headers.
- **Database:** Fixed a bug where `Postgre`, `OCI8`, and `SQLSRV` `Forge::_dropKeyAsConstraint()` interpolated table, constraint, and schema names without escaping.
- **Database:** Fixed a bug where `Postgre\Connection::insertID()` interpolated table, column, and sequence names without escaping.
Expand Down
4 changes: 2 additions & 2 deletions system/Cache/Handlers/PredisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ public function increment(string $key, int $offset = 1): int
{
$key = static::validateKey($key);

return $this->redis->hincrby($key, 'data', $offset);
return $this->redis->hincrby($key, '__ci_value', $offset);
}

public function decrement(string $key, int $offset = 1): int
{
$key = static::validateKey($key);

return $this->redis->hincrby($key, 'data', -$offset);
return $this->redis->hincrby($key, '__ci_value', -$offset);
}

public function clean(): bool
Expand Down
17 changes: 17 additions & 0 deletions tests/system/Cache/Handlers/PredisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,23 @@ public function testDeleteMatchingNothing(): void
$this->assertSame(0, $this->handler->deleteMatching('user_1_info*'));
}

public function testIncrementAndDecrement(): void
{
$this->handler->save('counter', 100);

foreach (range(1, 10) as $step) {
$this->handler->increment('counter', $step);
}

$this->assertSame(155, $this->handler->get('counter'));

$this->assertSame(135, $this->handler->decrement('counter', 20));
$this->assertSame(135, $this->handler->get('counter'));

$this->assertSame(140, $this->handler->increment('counter', 5));
$this->assertSame(140, $this->handler->get('counter'));
}

public function testClean(): void
{
$this->handler->save(self::$key1, 1);
Expand Down
Loading