Page to Content Migration - Fix url of legacy pages to avoid issues during migration
When migrating pages to content, conflicts with invalid urls usually interrupt the execution of the tool and require manipulation of database records.
Some of conflicts are:
-
assetname in table identifier does not match pageurl in table htmlpage (this stops the migration due to duplicated page_urls)
update htmlpage set pageurl = (select assetname from identifier where identifier.id = htmlpage.identifier);
-
Double dots before the extension of the page
update htmlpage set pageurl = replace(pageurl, '..', '.') where page_url like '%..%';
- Invalid characters in the url
update htmlpage set page_url = replace(page_url, ',', '') where page_url like '%,%';
update htmlpage set page_url = replace(page_url, '*', '') where page_url like '%*%';
update htmlpage set page_url = replace(page_url, '&', '') where page_url like '%&%';
etc
It'd be great if we could have a new FixTask to rename the pages to a valid URL before executing the page to content migration.
@agomez-dotcms please make sure we have the replace working (or equivalent) in all DBMSs
@dsilvam, @agomez-dotcms just asked me if it wouldn't make more sense to rename pages during the page to content migration instead of creating a FixTask that will be executed whether or not the client is getting ready to execute the page to content migration. I think he couldn't be more right about it!
Makes sense @gabbydotCMS let's do that
@agomez-dotcms, a fourth conflict when migrating legacy pages to content is when the page has a null template.
What I do in those cases is to locate the "Blank" template associated to the host where the page resides, so I would say that you should look for a live template containing the string "blank". If more than one, pick the first result you get to assign to the page. If none, then just pick one random template from the host to assign to the page. It'd be great to record an INFO message in the log every time the migration needs to assign a template to a page, so that we can report to the client what pages they'll need to review and most likely fix.
Thanks for all the effort you are investing on this fixes !!!!
I would delete the pages that have blank templates - they haven't and don't work and no one has said anything. It is not content being lost as any content on the page is still in the content repo.
@wezell, when fixing the inconsistencies manually with sql queries, updating the null template ID is less prone to generating new bad data than trying to remove the page from all the tables involved. However, since @agomez-dotcms is changing the migration process itself, deleting the legacy page and simply skipping the creation of the content should not be a trouble. I totally agree with you regarding the page not having worked before, so it shouldn't be a problem for the client either.
I always try put a NOT NULL constraints on almost every column. it really should be the default, and you should have to type more to get nullable columns, but i'm no joe celko
PR: https://github.com/dotCMS/core/pull/9977
Following changes have been implemented on HTML pages migration process (as part of previous pull-request - https://github.com/dotCMS/core/pull/9977):
- Page Url: by default, set from identifier's asset-name and with special/invalid characters rewritten
- Null Template Id: no content is converted and htmlpage is deleted
For testing purposes, you may want to ask for a database dump to @gabbydotCMS or myself in order to reproduce/validate issues and their corresponding fix ("fresh" database just migrated from 3.2 to 3.6). Due to data inconsistencies found, please notice that following script need to be run after restoring client's database dump and prior to execute HTML pages migration: https://gist.github.com/agomez-dotcms/cb746b1b1f2436c345764804022ca6f3
Hey Guys, I assigned this ticket back to In Review cause Gabby have found and fixed a bug related to the issue. Feel free to Merge and Assign back to "WF: Needs QA". Thanks, Anibal
Second PR: https://github.com/dotCMS/core/pull/10065
Passed QA Tested some scenarios such as:
- Double dots before the extension of the page
- Invalid characters in the url, i.e.: {..,!,:,;,&,?,$,*,,/,[,],=,|,#}
- Blank templates
Verified that Migrate to Content option works successfully
Executed query: select count(*) from htmlpage to make sure that count = 0 so pages are now content
Tested in latest master-3.7 and 3.7 distribution using a Postgres DB coming from a dotCMS 3.2 instance