Skip to content

Commit

Permalink
Merge pull request #16 from android-com-pl/analysis-lZLJEr
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
rafaucau committed Jun 16, 2023
2 parents 111915a + 008df91 commit b6be422
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
// Extensions
(new Extend\Conditional)
->whenExtensionEnabled('flarum-tags', [
(new Extend\Middleware('api'))->add(FlarumTagsPurgeMiddleware ::class),
(new Extend\Middleware('api'))->add(FlarumTagsPurgeMiddleware::class),
])
->whenExtensionEnabled('fof-masquerade', [
(new Extend\Middleware('api'))->add(FofMasqueradeMiddleware::class),
Expand Down
7 changes: 3 additions & 4 deletions src/Abstract/PurgeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface

// If this is just an update of the last read post, there is no point in clearing the public cache
if ($this->isDiscussion && Arr::get(
$request->getParsedBody(),
'data.attributes.lastReadPostNumber')
$request->getParsedBody(),
'data.attributes.lastReadPostNumber'
)
) {
return $response;
}


return $this->processPurge($request, $handler, $response);
}

Expand All @@ -56,7 +56,6 @@ abstract protected function processPurge(
ResponseInterface $response
): ResponseInterface;


protected function addPurgeParamsToResponse(ResponseInterface $response, array $newPurgeParams): ResponseInterface
{
if ($response->hasHeader(LSCacheHeadersEnum::PURGE)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Compatibility/FofMasquerade/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;


class Middleware extends PurgeMiddleware
{
protected function processPurge(
Expand All @@ -19,6 +18,7 @@ protected function processPurge(
// Purge user profile cache when updating FriendsOfFlarum/masquerade fields
if ($this->currentRouteName === 'masquerade.api.configure.save') {
$user = RequestUtil::getActor($request);

return $this->addPurgeParamsToResponse(
$response,
[
Expand Down
7 changes: 1 addition & 6 deletions src/Middleware/LSCachePurgeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@

use ACPL\FlarumCache\Abstract\PurgeMiddleware;
use ACPL\FlarumCache\LSCache;
use ACPL\FlarumCache\LSCacheHeadersEnum;
use Flarum\Discussion\Discussion;
use Flarum\Http\RequestUtil;
use Flarum\Post\Post;
use Flarum\Settings\SettingsRepositoryInterface;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

class LSCachePurgeMiddleware extends PurgeMiddleware
Expand All @@ -39,7 +34,7 @@ protected function processPurge(
if (! empty($purgeList)) {
$purgeList = explode("\n", $purgeList);
// Get only valid items
$purgeList = array_filter($purgeList, fn($item) => Str::startsWith($item, ['/', 'tag=']));
$purgeList = array_filter($purgeList, fn ($item) => Str::startsWith($item, ['/', 'tag=']));
$purgeParams = array_merge($purgeParams, $purgeList);
}

Expand Down
1 change: 0 additions & 1 deletion src/Middleware/LSTagsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use ACPL\FlarumCache\LSCache;
use ACPL\FlarumCache\LSCacheHeadersEnum;
use Laminas\Diactoros\Response\HtmlResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
Expand Down

0 comments on commit b6be422

Please sign in to comment.