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: android-com-pl/flarum-lscache
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.0
Choose a base ref
...
head repository: android-com-pl/flarum-lscache
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.2.0
Choose a head ref
  • 3 commits
  • 2 files changed
  • 3 contributors

Commits on Jun 18, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6215238 View commit details
  2. Apply fixes from StyleCI

    StyleCIBot committed Jun 18, 2023
    Copy the full SHA
    4efe470 View commit details
  3. Merge pull request #19 from android-com-pl/analysis-yrJB25

    Apply fixes from StyleCI
    rafaucau authored Jun 18, 2023
    Copy the full SHA
    44f6109 View commit details
Showing with 21 additions and 0 deletions.
  1. +1 −0 src/Compatibility/FlarumTags/FlarumTagsPurgeMiddleware.php
  2. +20 −0 src/Middleware/LSCachePurgeMiddleware.php
1 change: 1 addition & 0 deletions src/Compatibility/FlarumTags/FlarumTagsPurgeMiddleware.php
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ protected function processPurge(
return $response;
}

$response->getBody()->rewind();
$payload = $response->getBody()->getContents();
$payload = json_decode($payload, true);

20 changes: 20 additions & 0 deletions src/Middleware/LSCachePurgeMiddleware.php
Original file line number Diff line number Diff line change
@@ -43,6 +43,26 @@ protected function processPurge(
if (($isPostUpdate && Arr::has($body, 'data.attributes.isHidden')) || ! $isPostUpdate) {
array_push($purgeParams, 'tag=default', 'tag=index', 'tag=discussions.index');
}

// User profile cache
$response->getBody()->rewind();
$payload = json_decode($response->getBody()->getContents(), true);

if (isset($payload, $payload['included'])) {
$userData = Arr::first($payload['included'], fn ($value, $key) => $value['type'] === 'users');
if ($userData) {
$userId = $userData['id'];
$userName = Arr::get($userData, 'attributes.username');

array_push(
$purgeParams,
"tag=user_$userId",
"tag=user_$userName",
"tag=users_$userId",
"tag=users_$userName"
);
}
}
}

if ($isPost) {