sonata-project / SonataPageBundle

This bundle provides a Site and Page management through container and block services
https://docs.sonata-project.org/projects/SonataPageBundle
MIT License
219 stars 209 forks source link

Snapshot end date #786

Closed DidierPais closed 3 years ago

DidierPais commented 7 years ago

Environment

Sonata packages

$ composer show sonata-project/*
sonata-project/admin-bundle              3.13.0 The missing Symfony Admin Generator
sonata-project/block-bundle              3.3.0  Symfony SonataBlockBundle
sonata-project/cache                     1.0.7  Cache library
sonata-project/cache-bundle              2.3.1  This bundle provides caching services
sonata-project/core-bundle               3.2.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.2.1  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.1.3  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.1.10 Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.7.1  Lightweight Exporter library
sonata-project/google-authenticator      1.0.2  Library to integrate Google Authenticator into a PHP project
sonata-project/intl-bundle               2.3.0  Symfony SonataIntlBundle
sonata-project/notification-bundle       3.1.0  Symfony SonataNotificationBundle
sonata-project/page-bundle               3.3.0  This bundle provides a Site and Page management through container and block services
sonata-project/seo-bundle                2.1.0  Symfony SonataSeoBundle
sonata-project/user-bundle               3.2.1  Symfony SonataUserBundle

Symfony packages

$ composer show symfony/*
symfony/monolog-bundle     2.11.3  Symfony MonologBundle
symfony/phpunit-bridge     v2.8.17 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.3.0  Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.3.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.3.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php54     v1.3.0  Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55     v1.3.0  Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56     v1.3.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.3.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.3.0  Symfony utilities for portability of PHP codes
symfony/security-acl       v3.0.0  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.4.2  Symfony SwiftmailerBundle
symfony/symfony            v2.8.17 The Symfony PHP framework

PHP version

$ php -v
PHP 7.0.13 (cli) (built: Nov 15 2016 00:04:01) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.13, Copyright (c) 1999-2016, by Zend Technologies
    with Xdebug v2.5.0, Copyright (c) 2002-2016, by Derick Rethans

Subject

Hello,

When I create a snapshot for a page, it ends all previous ones with today's date. But when I set a start date for the new snapshot, it doesn't update the previous one's end date. Which causes a 404 between the last snapshot end date and the new snapshot start date.

image

In this exemple we will have a 404 error between 2017/02/16 and 2017/02/24

Steps to reproduce

Create a first snapshot. Create a second one, update the start date and the end date. Create a third one.

You will see that all previous snapshots end date have been updated to today's date. This is a problem because we can't configure a set of snapshots and will cause 404 errors.

Expected results

When creating a new snapshot, let the user set the start date, which will be the end date of the previous one. And not all the previous ones.

Actual results

When creating a new snapshot, ALL the previous ones' end date are set to today's date.

haivala commented 7 years ago

same problem here

greg0ire commented 7 years ago

Can one of you bisect the branch down to the commit that introduced the bug?

DidierPais commented 7 years ago

Hello,

I don't know which commit introduced the bug. I think that is a bug which exists from a long time

haivala commented 7 years ago

I would say this is confirmed bug but nobody knows when it was introduced..

clairemariko commented 7 years ago

Has this issue been resolved? As I have the same problem

greg0ire commented 7 years ago

Has this issue been resolved? As I have the same problem

I think you just answered your own question :trollface:

stale[bot] commented 4 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

haivala commented 3 years ago

is it this one? https://github.com/sonata-project/SonataPageBundle/blame/a2d83e6c02f566222bc04827885566d981270176/Entity/SnapshotManager.php#L86

haivala commented 3 years ago

yeah so the query just needs AND publication_date_end IS NULL at the end and it'll fix this problem so that the query does not effect all of the snapshots

I think that this is not the place where the date should be defined. While creating a new snapshot (probably in postCreate?) we should take the publication_date_start and update that to the publication_date_end on the last snapshot.

actually the CreateSnapshotType should have the date..