pnp / pnpframework

PnP Framework is a .NET library targeting Microsoft 365 containing the PnP Provisioning engine and a ton of other useful extensions
https://pnp.github.io/pnpframework/
MIT License
205 stars 142 forks source link

[BUG] Wiki Page Internal Links Missing "SitePages" #617

Open sympmarc opened 2 years ago

sympmarc commented 2 years ago

Problem Area

[x] Page Transformation: Error during the use of page transformation from PnP PowerShell [ ] Page Transformation: Error during the use of page transformation from .Net [ ] Page Transformation: Page is not looking correct after transformation [ ] Modernization Scanner: something went wrong...

Expected or Desired Behavior

I'm converting a Wiki library in SharePoint 2010 to SharePoint Online. Because I'm converting from SP2010, I'm using SharePointPnPPowerShell v 3.29.2101.0, which as I understand it is the last version which works with SP2010. The files convert beautifully, though they are placed into a folder in the Site Pages library, as mentioned in pnp/pnpframework#626. The pages also aren't published in the destination.

Observed Behavior

The bug is with the links inside the pages. They aren't fixed up properly. The pages end up in a folder called Wiki, as that is the name of the source Wiki library.

So, the pages land in appropriate locations. But the lniks insode the pages are missing the SitePages part of the URLs:

Steps to Reproduce

My PowerShell looks something like below. I've tried every combination of the property settings (-Target*) I can think of to remedy this. I've also had @ToddKlindt take a look to make sure I'm not doing something dumb. Am I holding it wrong?

Import-Module -Name SharePointPnPPowerShellOnline

$sourceSiteUrl = "sourceSiteUrl"
$targetSiteUrl = "targetSiteUrl"
$sourceLibrary = "Wiki"

$sourceConnection = Connect-PnPOnline -Url $sourceSiteUrl -ReturnConnection -Credential (Get-StoredCredential -Target "Marc")
$targetConnection = Connect-PnPOnline -Url $targetSiteUrl -ReturnConnection -UseWebLogin

$wikiPages = Get-PnPListItem -Connection $sourceConnection -List $sourceLibrary -PageSize 500

$filteredWikiPages = $wikiPages | Select-Object -First 5

foreach ($page in $filteredWikiPages) {

    $targetPageName = $page.FieldValues.FileLeafRef

    Write-Host "Writing page <$($page.FieldValues.FileLeafRef)> to <$($targetPageName)>"

    ConvertTo-PnPClientSidePage `
        -Connection $sourceConnection `
        -Library $sourceLibrary `
        -Identity $page.FieldValues["ID"] `
        -Overwrite `
        -CopyPageMetadata `
        -TargetConnection $targetConnection `
        -TargetPageName $targetPageName `
        -LogType File -LogFolder .

}

p.s. Convert-WikiAndWebPartPages.ps1 doesn't seem to be all that tuned for Wiki pages. Most Wikis in older on premises versions are going to be in a separate library from SitePages.

sympmarc commented 2 years ago

I realized I'm getting an error on each page, even though it's being copied into the destination. I expect this has something to do with the issue. One example below; all 5 pages I'm testing with get the same error.

Modernization Summary Report

Date Duration Source Page Target Page Url Status
3/4/2022 2:37:27 PM 00:00:05 /CCR/Wiki/Creating a CCR BASE.aspx []() A issue prevented successful transformation

Critical Errors during transformation

3/4/2022 2:37:33 PM - [/CCR/Wiki/Creating a CCR BASE.aspx](https://iknow/sites/AppS/CCR/Wiki/Creating a CCR BASE.aspx)

Object reference not set to an instance of an object. at SharePointPnP.Modernization.Framework.Cache.CacheManager.GetFieldsToCopy(Web web, List sourceLibrary, String pageType) at SharePointPnP.Modernization.Framework.Transform.BasePageTransformator.CopyPageMetadata(PageTransformationInformation pageTransformationInformation, String pageType, ClientSidePage targetPage, List targetPagesLibrary) at SharePointPnP.Modernization.Framework.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation)

jansenbe commented 2 years ago

@sympmarc : As we've deprecated that build of PnP and as such also the support for migrating from SP2010 we can't make any code changes anymore, but just wanted to verify if you've played with these options to avoid getting the pages ending up in the "wiki" folder? Did not yet test myself, but hopefully this can help.

image

sympmarc commented 2 years ago

Yeah, I know I'm in oldster land. I have to be for SP2010, right?

I have played with those in every combination I can think of. I can make the pages land in a different folder in SitePages, but I can't seem to have any effect on the internal URLs.

sympmarc commented 2 years ago

I turned on -LogVerbose and it shows me all the steps, but with no errors other than the one above. I'm wondering if there's some way to copy into SPO, then fix up the links from there. It would be messier, but maybe my only option?

sympmarc commented 2 years ago

FYI - I decided to migrate the Wiki into SPO with ShareGate. Now I can run the page transformation on it with up-to-date PnP.PowerShell. I think this approach will work.

sympmarc commented 2 years ago

@jansenbe - I'm reopening this to keep the context - let me know if you'd prefer a new issue.

I now have the Wiki in classic mode at /sites/siteName/Wiki. I'd like to convert the Wiki to pages in /sites/siteName/SitePages. As above, the transformation happens, then new pages are created in /sites/siteName/SitePages/Wiki (whether I want this folder or not doesn't matter right now), but the links in the pages aren't "fixed up". They actually still point to the Wiki pages in /sites/siteName/Wiki.

As before, I wanted to start simple, so I'm doing this with PnP.PowerShell 1.9.0:

    ConvertTo-PnPPage ` 
        -Connection $sourceConnection `
        -Library $sourceLibrary `
        -Identity $page.FieldValues["ID"] `
        -Overwrite `
        -TargetPageName $targetPageName `
        -KeepPageCreationModificationInformation `
        -CopyPageMetadata `
        -LogType File `
        -LogFolder "./logs" `
        -LogVerbose

Given the pages are Wiki pages, I'd expect the links to be fixed up - that's a big part of a Wiki, obviously.

Looking at the log for Home.aspx, which is basically one big Content Editor Web Part with text and links, everything seems like it's set correctly to understand a Wiki page. So, same question as before: am I holding it wrong or is there a bug?

Modernization Summary Report

Date Duration Source Page Target Page Url Status
3/8/2022 8:22:31 AM 00:00:04 /Wiki/Home.aspx /SitePages/Wiki/Migrated_Home.aspx Successful

Individual Page details

Transformation Details: /Wiki/Home.aspx

Page Transformation Settings

Property Setting
Engine version 1.8.3.0
Target Page Takes Source Page Name False
Target Page Prefix Migrated_
Source Page Prefix Previous_
Copy Page Metadata True
Set Author In Page Header False
Replace Home Page With Default Home Page False
Overwrite True
Target Page Name
Target Page Folder
Target Page Folder Overrides Default Folder False
Keep Page Specific Permissions True
Remove Empty Sections And Columns True
Handle Wiki Images And Videos True
Add Table List Image As Image Web Part True
Keep Page Creation Modification Information True
Publish Created Page True
Post As News False
Disable Page Comments False
Skip Url Rewrite False
Skip Default Url Rewrite False
Url Mapping File
Skip Hidden Web Parts False
Term Mapping File
Skip Term Store Mapping False
Skip User Mapping False
User Mapping File
L D A P Connection String
Skip Telemetry False

Transformation Operation Details

Date Operation Actions Performed
3/8/2022 8:22:31 AM Input Validation Validation checks complete
3/8/2022 8:22:31 AM SharePoint Connection Loading client context objects
3/8/2022 8:22:31 AM Page Creation Detect if the page is living inside a folder
3/8/2022 8:22:31 AM Page Creation The transform page is located in a folder
3/8/2022 8:22:31 AM Page Creation Using the supplied prefix
3/8/2022 8:22:31 AM Page Creation Just try to load the page in the fastest possible manner, we only want to see if the page exists or not
3/8/2022 8:22:31 AM Load Page does not exist in current web
3/8/2022 8:22:31 AM Page Creation Checking Page Exists
3/8/2022 8:22:32 AM Page Creation Modern page created
3/8/2022 8:22:32 AM Home page handling Check if the transformed page is the web's home page
3/8/2022 8:22:32 AM Home page handling Welcome page setting does exist, checking if the transform page is a home page
3/8/2022 8:22:32 AM Home page handling The current page is used as a home page - settings modern page to 'Home' layout
3/8/2022 8:22:32 AM Article page handling Transforming source page as Article page
3/8/2022 8:22:32 AM Article page handling Page Header Set to None. Removing the page header
3/8/2022 8:22:32 AM Article page handling Recognized source page as a Wiki Page. - Analyzing web parts and page layouts
3/8/2022 8:22:32 AM Article page handling No web parts were found on page
3/8/2022 8:22:32 AM Article page handling Splitting images and videos from wiki text - as modern text web part does not support embedded images and videos
3/8/2022 8:22:32 AM Set Page Title Setting the modern page title: Home
3/8/2022 8:22:32 AM Article page handling Preparing content transformation
3/8/2022 8:22:32 AM Article page handling Transforming content
3/8/2022 8:22:32 AM Content Transform Transforming web parts
3/8/2022 8:22:32 AM Web Part Mapping Web Part:'WikiText' of type 'SharePointPnP.Modernization.WikiTextPart' is being transformed
3/8/2022 8:22:32 AM Web Part Mapping Processing selector functions
3/8/2022 8:22:32 AM Web Part Mapping Combining mapping data
3/8/2022 8:22:32 AM Adding Web Parts to Target Page Added 'Client Side Text Web Part' to target page
3/8/2022 8:22:32 AM Content Transform Transforming web parts complete
3/8/2022 8:22:32 AM Article page handling Transforming content complete
3/8/2022 8:22:33 AM Article page handling Saved page: Wiki/Migrated_Home.aspx
3/8/2022 8:22:33 AM Item level permissions Item level permissions read
3/8/2022 8:22:35 AM Page Creation Transformation Complete