Skip to content

Commit

Permalink
Merge branch 'master' into fix-item-get_base
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkarex authored Sep 29, 2024
2 parents 2c468af + 194f8ff commit 3eefc01
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
- '8.4'

name: "PHP: ${{ matrix.php }}"
continue-on-error: ${{ matrix.php == '8.3' }}
continue-on-error: ${{ matrix.php == '8.4' }}

steps:
- name: Checkout code
Expand All @@ -63,12 +71,12 @@ jobs:

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: "Install Composer dependencies (PHP < 8.3)"
if: ${{ matrix.php < '8.3' }}
- name: "Install Composer dependencies (PHP < 8.4)"
if: ${{ matrix.php < '8.4' }}
uses: "ramsey/composer-install@v2"

- name: "Install Composer dependencies (PHP 8.3)"
if: ${{ matrix.php >= '8.3' }}
- name: "Install Composer dependencies (PHP 8.4)"
if: ${{ matrix.php >= '8.4' }}
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-reqs
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
},
"config": {
"bin-dir": "bin",
"lock": false,
"sort-packages": true
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/SimplePie.php
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ protected function fetch_data(&$cache)
$this->data = [];
}
// Check if the cache has been updated
elseif (isset($this->data['cache_expiration_time']) && $this->data['cache_expiration_time'] > time()) {
elseif (!isset($this->data['cache_expiration_time']) || $this->data['cache_expiration_time'] < time()) {
// Want to know if we tried to send last-modified and/or etag headers
// when requesting this file. (Note that it's up to the file to
// support this, but we don't always send the headers either.)
Expand All @@ -1924,6 +1924,7 @@ protected function fetch_data(&$cache)
$this->status_code = 0;

if ($this->force_cache_fallback) {
$this->data['cache_expiration_time'] = $this->cache_duration + time();
$cache->set_data($cacheKey, $this->data, $this->cache_duration);

return true;
Expand All @@ -1936,6 +1937,7 @@ protected function fetch_data(&$cache)
// Set raw_data to false here too, to signify that the cache
// is still valid.
$this->raw_data = false;
$this->data['cache_expiration_time'] = $this->cache_duration + time();
$cache->set_data($cacheKey, $this->data, $this->cache_duration);

return true;
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/CachingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function testInitWithDifferentCacheStateCallsCacheCorrectly(
*/
public static function provideSavedCacheData(): array
{
$defaultMtime = time();
$defaultMtime = time() - 1; // -1 to account for tests running within the same second
$defaultExpirationTime = $defaultMtime + 3600;

$expectDefaultDataWritten = [
Expand Down Expand Up @@ -246,10 +246,10 @@ public static function provideSavedCacheData(): array
[CacheInterface::class, $currentlyCachedDataWithNonFeedUrl, $expectDataWithNewFeedUrl, $defaultMtime],
// Check if the cache has been updated
[Base::class, $currentlyCachedDataIsUpdated, $expectDefaultDataWritten, $defaultMtime],
[CacheInterface::class, $currentlyCachedDataIsUpdated, $expectDefaultDataWritten, $defaultMtime],
[CacheInterface::class, $currentlyCachedDataIsUpdated, $expectNoDataWritten, $defaultMtime],
// If the cache is still valid, just return true
[Base::class, $currentlyCachedDataIsValid, $expectDefaultDataWritten, $defaultMtime],
[CacheInterface::class, $currentlyCachedDataIsValid, $expectNoDataWritten, $defaultMtime],
[CacheInterface::class, $currentlyCachedDataIsValid, $expectDefaultDataWritten, $defaultMtime],
];
}
}

0 comments on commit 3eefc01

Please sign in to comment.