Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: laravel/jetstream
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.1.1
Choose a base ref
...
head repository: laravel/jetstream
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.1.2
Choose a head ref
  • 2 commits
  • 3 files changed
  • 3 contributors

Commits on Nov 28, 2023

  1. Update CHANGELOG

    driesvints authored and github-actions[bot] committed Nov 28, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c0aa1cb View commit details

Commits on Nov 29, 2023

  1. [4.x] Fix Browser Sessions not showing platform and browser (#1412)

    * use simple key value store
    
    * Add failing tests for PR #1412
    
    Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
    
    * wip
    
    Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
    
    ---------
    
    Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
    Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
    olumby and crynobone authored Nov 29, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    252348e View commit details
Showing with 28 additions and 18 deletions.
  1. +6 −1 CHANGELOG.md
  2. +14 −15 src/Agent.php
  3. +8 −2 tests/AgentTest.php
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Release Notes

## [Unreleased](https://github.com/laravel/jetstream/compare/v4.1.0...4.x)
## [Unreleased](https://github.com/laravel/jetstream/compare/v4.1.1...4.x)

## [v4.1.1](https://github.com/laravel/jetstream/compare/v4.1.0...v4.1.1) - 2023-11-27

* deleteTeam() return type by [@tanthammar](https://github.com/tanthammar) in https://github.com/laravel/jetstream/pull/1406
* Set password in session on update for inertia by [@taylorotwell](https://github.com/taylorotwell) in https://github.com/laravel/jetstream/pull/1411

## [v4.1.0](https://github.com/laravel/jetstream/compare/v4.0.5...v4.1.0) - 2023-11-07

29 changes: 14 additions & 15 deletions src/Agent.php
Original file line number Diff line number Diff line change
@@ -3,8 +3,6 @@
namespace Laravel\Jetstream;

use Closure;
use Detection\Cache\CacheException;
use Detection\Exception\MobileDetectException;
use Detection\MobileDetect;

/**
@@ -50,6 +48,13 @@ class Agent extends MobileDetect
'WeChat' => 'MicroMessenger',
];

/**
* Key value store for resolved strings.
*
* @var array<string, mixed>
*/
protected $store = [];

/**
* Get the platform name from the User Agent.
*
@@ -126,24 +131,18 @@ protected function findDetectionRulesAgainstUserAgent(array $rules)
* @param string $key
* @param \Closure():mixed $callback
* @return mixed
*
* @throws \Detection\Exception\MobileDetectException
*/
protected function retrieveUsingCacheOrResolve(string $key, Closure $callback)
{
try {
$cacheKey = $this->createCacheKey($key);
$cacheKey = $this->createCacheKey($key);

if (! is_null($cacheItem = $this->cache->get($cacheKey))) {
return $cacheItem->get();
}

return tap(call_user_func($callback), function ($result) use ($cacheKey) {
$this->cache->set($cacheKey, $result);
});
} catch (CacheException $e) {
throw new MobileDetectException("Cache problem in for {$key}: {$e->getMessage()}");
if (! is_null($cacheItem = $this->store[$cacheKey] ?? null)) {
return $cacheItem;
}

return tap(call_user_func($callback), function ($result) use ($cacheKey) {
$this->store[$cacheKey] = $result;
});
}

/**
10 changes: 8 additions & 2 deletions tests/AgentTest.php
Original file line number Diff line number Diff line change
@@ -22,7 +22,10 @@ public function testOperatingSystems($userAgent, $platform)
$agent = new Agent();
$agent->setUserAgent($userAgent);

$this->assertEquals($platform, $agent->platform());
$this->assertSame($platform, $agent->platform());

// Test cached value return the same output.
$this->assertSame($platform, $agent->platform());
}

public static function operatingSystemsDataProvider()
@@ -48,7 +51,10 @@ public function testBrowsers($userAgent, $browser)
$agent = new Agent();
$agent->setUserAgent($userAgent);

$this->assertEquals($browser, $agent->browser());
$this->assertSame($browser, $agent->browser());

// Test cached value return the same output.
$this->assertSame($browser, $agent->browser());
}

public static function browsersDataProvider()