Commit 911a3eb0 authored by Marc Egger's avatar Marc Egger
Browse files

Refs #12588 fix bug, make slug migration exception nicer

parent 4c17f442
Pipeline #5399 failed with stages
in 2 minutes and 7 seconds
......@@ -275,7 +275,7 @@ class DatabaseUpdate {
#####################################################################################
##### ONLY RUN THIS FUNCTION IF TYPO3 VERSION 9 OR HIGHER AND NOT API ENDPOINT #####
if (!T3Handler::isTypo3Loaded() || !T3Handler::typo3VersionGreaterEqual9()) {
if ( ! (T3Handler::isTypo3Loaded() && T3Handler::useSlugsInsteadOfPageAlias()) ) {
return null;
}
......@@ -284,7 +284,8 @@ class DatabaseUpdate {
##### COMPUTE MIGRATION MODE #####
// read variable "RUN_PAGE_SLUG_MIGRATION_CHECK" from qfq.json
$forceRunMigrationCheck = Config::get(FORCE_RUN_PAGE_SLUG_MIGRATION_CHECK) === true;
$x = Config::get(FORCE_RUN_PAGE_SLUG_MIGRATION_CHECK);
$forceRunMigrationCheck = ($x === true || $x === "true");
// if db flag "done" or "skip" then skip check
if (!$forceRunMigrationCheck && ($dBMigrationFlag === QFQ_VERSION_KEY_SLUG_MIGRATION_DONE || $dBMigrationFlag === QFQ_VERSION_KEY_SLUG_MIGRATION_SKIP)) {
......@@ -292,7 +293,7 @@ class DatabaseUpdate {
}
// get value from GET parameter ACTION_SLUG_MIGRATION_UPDATE
$actionSlugMigration = $_GET[ACTION_SLUG_MIGRATION_UPDATE] ?? '';
$actionSlugMigration = ($_GET[ACTION_SLUG_MIGRATION_UPDATE] ?? '');
// if GET parameter "skipForever" then write "skip" to db
if (!$forceRunMigrationCheck && $actionSlugMigration === ACTION_SLUG_MIGRATION_DO_SKIP_FOREVER) {
......@@ -305,7 +306,7 @@ class DatabaseUpdate {
}
// if GET parameter or session is "pause" then skip check and show message
if ($actionSlugMigration === ACTION_SLUG_MIGRATION_DO_PAUSE || $_SESSION[ACTION_SLUG_MIGRATION_UPDATE] ?? '' === ACTION_SLUG_MIGRATION_DO_PAUSE) {
if ($actionSlugMigration === ACTION_SLUG_MIGRATION_DO_PAUSE || ($_SESSION[ACTION_SLUG_MIGRATION_UPDATE] ?? '') === ACTION_SLUG_MIGRATION_DO_PAUSE) {
$_SESSION[ACTION_SLUG_MIGRATION_UPDATE] = ACTION_SLUG_MIGRATION_DO_PAUSE;
QuickFormQuery::$systemMessages[] = 'Page slug migration paused. '
. '<a href="?' . ACTION_SLUG_MIGRATION_UPDATE . '=' . ACTION_SLUG_MIGRATION_DO_RESUME . '">Resume migration</a>';
......@@ -617,7 +618,7 @@ class DatabaseUpdate {
// if no occurrences were found then set db flag to "done"
if ($message === '' && !$doReplace) {
if ($forceRunMigrationCheck) {
Thrower::dbException('Page Slug Migration.', 'No alias patterns where found. Please disable the setting ' . FORCE_RUN_PAGE_SLUG_MIGRATION_CHECK . ' in qfq.json');
Thrower::dbException('Page Slug Migration.', 'No occurrences of page alias where found. Please disable the setting ' . FORCE_RUN_PAGE_SLUG_MIGRATION_CHECK . ' in ' . CONFIG_QFQ_JSON);
}
return QFQ_VERSION_KEY_SLUG_MIGRATION_DONE;
}
......@@ -646,31 +647,44 @@ class DatabaseUpdate {
. 'Usages of page alias found. The Typo3 feature "page alias" has been replaced by the "page slug" feature and can no longer be used in links with "?id=[alias]".'
. '<h2>SOLUTION</h2>'
. "<ul>"
. '<li>The special column _link now treats the "p:" parameter value as a page slug if it starts with "/".</li>'
. '<li>Use {{pageSlug:T}} instead of {{pageAlias:T}} and {{pageId:T}} in the _link columns.</li>'
. '<li>Use {{baseUrlLang:Y}}/{{pageSlug:T}} instead of {{pageAlias:T}} and {{pageId:T}} in hardcoded ' . htmlentities("<a>") . ' tags.</li>'
. '<li>The special column _link now treats the "p:" parameter value as a page slug.</li>'
. '<li>Use {{pageSlug:T}} instead of {{pageAlias:T}} or {{pageId:T}} in the _link columns.</li>'
. '<li>Use {{baseUrlLang:Y}}/{{pageSlug:T}} instead of {{pageAlias:T}} or {{pageId:T}} in hardcoded ' . htmlentities("<a>") . ' tags.</li>'
. '<li>Replace hardcoded aliases in QFQ code with the slugs of the pages.</li>'
. "</ul>"
. '<br>In the report below the suggested changes are prominently marked with colour.'
. '<h2>AUTO SUGGESTIONS</h2>'
. 'In the report below the suggested changes are prominently marked with colour.'
. "<br> If there is a $noSuggestionSymbol then there is no suggestion and you will have to fix it manually."
. "<br> Tip: use ctrl+f and copy $noSuggestionSymbol into the search bar."
. "<br> Tip: use ctrl+f and copy $noSuggestionSymbol into the search bar to quickly jump between matches."
. '<h2>ACTIONS</h2>'
. "<ul>"
. '<li><a href="?' . ACTION_SLUG_MIGRATION_UPDATE . '=' . ACTION_SLUG_MIGRATION_DO_REPLACE . '">Auto replace</a>'
. ' occurrences of page aliases and page ids with the suggested page slug.'
. '<br>A report file will be saved to "' . Path::absoluteLog() . '" after the automatic replacement. </li>'
. ' <li>To use the Form Editor you can '
. '<a href="?' . ACTION_SLUG_MIGRATION_UPDATE . '=' . ACTION_SLUG_MIGRATION_DO_PAUSE . '">pause the migration temporarliy</a>.</li>'
. '<li>You may also '
. '<a href="?' . ACTION_SLUG_MIGRATION_UPDATE . '=' . ACTION_SLUG_MIGRATION_DO_SKIP_FOREVER . '">skip this check forever</a> but your app will probably be broken.'
. '<br>To reenable the check you can set the config variable ' . FORCE_RUN_PAGE_SLUG_MIGRATION_CHECK . ' to "true" in ' . CONFIG_QFQ_JSON . '</li>'
. "</ul>"
. '<br><br>Click <a href="?' . ACTION_SLUG_MIGRATION_UPDATE . '=' . ACTION_SLUG_MIGRATION_DO_REPLACE . '">auto-replace</a>'
. ' to automatically replace occurrences of page aliases and page ids with the page slug.'
. '<br>An HTML report will be saved to "' . Path::absoluteLog() . '" after the automatic replacement.'
. ' <br><br>To pause this migration and to use the Form Editor click: '
. '<a href="?' . ACTION_SLUG_MIGRATION_UPDATE . '=' . ACTION_SLUG_MIGRATION_DO_PAUSE . '">Pause-migration</a>'
. ' <br><br>To skip this check forever click: '
. '<a href="?' . ACTION_SLUG_MIGRATION_UPDATE . '=' . ACTION_SLUG_MIGRATION_DO_SKIP_FOREVER . '">Skip-check-forever</a> (your app will probably be broken)'
. ($forceRunMigrationCheck ? '<br><br>Note: setting ' . FORCE_RUN_PAGE_SLUG_MIGRATION_CHECK . ' is active in qfq.json.' : '')
. '<h2>Overview Replacement Suggestions</h2>'
. join('<br>', array_unique($allMatches))
. '<h2>Report: Suggestions Marked with Red Color in Code</h2>'
. '<h2>Report: Occurrences Marked with Red Color in Code</h2>'
. $message;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment