pnpcore icon indicating copy to clipboard operation
pnpcore copied to clipboard

Page.Save() overwrites history

Open jensotto opened this issue 2 years ago • 1 comments

Category

  • [x] Bug

Describe the bug

Saving changes made to a page does not create a new version of the page, and keeps the modifier and modified date of the current page version. This also results in that the comparison of changes made between current version and previous version is changed, effectively leaving the modifier of the page original current version as the one that updated the page using Page.Save(). It can also happen that it appears like web part(s) that was added in the previous version and removed by Page.Components[0].Delete() and Page.Save() never existed on the page.

Steps to reproduce

  1. Create a new blank modern page.
  2. Set the title to "Versions".
  3. Add some text to the text web part.
  4. Publish the page
  5. Wait at least one minute (just to make it easy to see diference in modified date)
  6. Execute the following PowerShell code (to get the best experience you should log in with a different user):
Connect-PnPOnline -Interactive <URL to site>
$page = Get-PnPPage versions.aspx
$page.Controls[0].Delete()
$page.Save()
  1. Refresh the page -> notice that the web part has been removed.
  2. Click on page details
  3. Click on Version history
  4. Notice that the original modified by and modified date is still showing, and that changes since page creation does not have any record of the text web part.

The same behavior can be observed on existing pages with a long history (for example).

Expected behavior

New version created when using save, optionally arguments (boolean/enum) to control if system update , system update overwrite version or immediate publish of the new version should be used.

Environment details (development & target environment)

  • SDK version: Same as PnP.PowerShell 1.10.0 (1.6.1.0)
  • OS: Windows 10
  • SDK used in: PowerShell
  • Framework: PowerShell 7/5.1
  • Browser(s): N/A
  • Tooling: N/A
  • Additional details:

Additional context

jensotto avatar Jul 01 '22 13:07 jensotto

We also need this feature but in the context of PnP provisioning. This might be a bit more difficult to achieve because multiple saves might contribute to only one new version. The experience should be: there is an existing page. A PnP template is applied, updating the page and this creates one new version. My 2 cents.

heinrich-ulbricht avatar Sep 02 '22 10:09 heinrich-ulbricht

@jensotto / @heinrich-ulbricht : given we've shipped an official pages API (in beta for now) and we're planning to make that one feature complete I'm going to close this one for now.

jansenbe avatar Feb 13 '23 11:02 jansenbe

What does this mean @jansenbe ? Could you please detail what you suggest a bit further? Is this available somewhere to use and where? Does this mean that this now works as expected?

jensotto avatar Feb 13 '23 11:02 jensotto

Eventually we'll replace the PnP implementation by the official API (only one's its ready and in v1.0). With the new API every page update will be a new version

jansenbe avatar Feb 13 '23 11:02 jansenbe

I love it!! Can't wait :)

heinrich-ulbricht avatar Feb 13 '23 13:02 heinrich-ulbricht

Closing per previous remarks. Once we integrate the official page API the feature you've requested will be there. We'll limit updates to the "PnP" version to a minimum until then.

jansenbe avatar Feb 21 '23 09:02 jansenbe