Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CreateSnapshotAdminExtension bug fix #1709

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Admin/Extension/CreateSnapshotAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function postPersist(AdminInterface $admin, object $object): void

public function postRemove(AdminInterface $admin, object $object): void
{
if ($object instanceof PageInterface) {
return;
}

$this->createByPage($object);
Comment on lines +43 to 47
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with this lib, maybe you can explain to me the change behind ?

SOmething like:
"This extension is used to create a snapshot of a Page. When you persist/update a Page or a PageBlock you want to update the snapshot of the Page. But when you remove something, the snapshot should only be updated if we remove a PageBlock. When we removed a Page, the snapshot should just be deleted with the page" ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works on my side. It prevent the snapshot to re-create the page on page deletion.

}

Expand Down
2 changes: 1 addition & 1 deletion src/Route/RoutePageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@
if (
!$this->decoratorStrategy->isRouteNameDecorable($name)
|| !$this->decoratorStrategy->isRouteUriDecorable($route->getPath())
|| (null !== $routeHostRegex
|| (\is_string($routeHostRegex)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null !== $routeHostRegex
&& '' !== $routeHostRegex
&& ...

Will fix the psalm error

&& 0 === preg_match($routeHostRegex, $site->getHost() ?? ''))

Check failure on line 81 in src/Route/RoutePageGenerator.php

View workflow job for this annotation

GitHub Actions / Psalm

ArgumentTypeCoercion

src/Route/RoutePageGenerator.php:81:37: ArgumentTypeCoercion: Argument 1 of preg_match expects non-empty-string, but parent type string provided (see https://psalm.dev/193)
) {
if (null !== $page) {
$page->setEnabled(false);
Expand Down