Skip to content

Commit

Permalink
[!!!][TASK] Remove database field pages.alias
Browse files Browse the repository at this point in the history
This is a precursor for removing PseudoSiteHandling in general.

The database field "pages.alias" field is dropped, along with
the functionality to evalute if a frontend request "?id=acme"
is non-integer, as it now always has to be integer.

Existing links pointing to page aliases will stop working.

Resolves: #87356
Releases: master
Change-Id: I19134cc788e633e140b43497f716082ac96744e5
Reviewed-on: https://review.typo3.org/59232
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
  • Loading branch information
bmack authored and wouter90 committed Jan 7, 2019
1 parent cee72a1 commit 24b08ef
Show file tree
Hide file tree
Showing 42 changed files with 88 additions and 459 deletions.
30 changes: 1 addition & 29 deletions typo3/sysext/backend/Classes/Controller/BackendController.php
Expand Up @@ -21,9 +21,6 @@
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Imaging\IconFactory;
Expand Down Expand Up @@ -433,34 +430,9 @@ protected function handlePageEditing()
if ($editId) {
// Looking up the page to edit, checking permissions:
$where = ' AND (' . $beUser->getPagePermsClause(Permission::PAGE_EDIT) . ' OR ' . $beUser->getPagePermsClause(Permission::CONTENT_EDIT) . ')';
$editRecord = null;
if (MathUtility::canBeInterpretedAsInteger($editId)) {
$editRecord = BackendUtility::getRecordWSOL('pages', $editId, '*', $where);
} else {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));

$editRecord = $queryBuilder->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq(
'alias',
$queryBuilder->createNamedParameter($editId, \PDO::PARAM_STR)
),
$queryBuilder->expr()->orX(
$beUser->getPagePermsClause(Permission::PAGE_EDIT),
$beUser->getPagePermsClause(Permission::CONTENT_EDIT)
)
)
->setMaxResults(1)
->execute()
->fetch();

if ($editRecord !== false) {
BackendUtility::workspaceOL('pages', $editRecord);
}
}
// If the page was accessible, then let the user edit it.
if (is_array($editRecord) && $beUser->isInWebMount($editRecord['uid'])) {
Expand Down
Expand Up @@ -291,7 +291,6 @@ protected function pagesToFlatArray(array $page, int $entryPoint, int $depth = 0
'icon' => $icon->getIdentifier(),
'name' => $visibleText,
'nameSourceField' => $nameSourceField,
'alias' => htmlspecialchars($page['alias'] ?? ''),
'prefix' => htmlspecialchars($prefix),
'suffix' => htmlspecialchars($suffix),
'locked' => is_array($lockInfo),
Expand Down
Expand Up @@ -48,7 +48,6 @@ class PageTreeRepository
'title',
'nav_title',
'nav_hide',
'alias',
'php_tree_stop',
'doktype',
'is_siteroot',
Expand Down
8 changes: 1 addition & 7 deletions typo3/sysext/backend/Classes/Utility/BackendUtility.php
Expand Up @@ -1250,7 +1250,7 @@ public static function thumbCode(
}

/**
* Returns title-attribute information for a page-record informing about id, alias, doktype, hidden, starttime, endtime, fe_group etc.
* Returns title-attribute information for a page-record informing about id, doktype, hidden, starttime, endtime, fe_group etc.
*
* @param array $row Input must be a page row ($row) with the proper fields set (be sure - send the full range of fields for the table)
* @param string $perms_clause This is used to get the record path of the shortcut page, if any (and doktype==4)
Expand All @@ -1266,9 +1266,6 @@ public static function titleAttribForPages($row, $perms_clause = '', $includeAtt
$out = htmlspecialchars($parts[0]);
return $includeAttrib ? 'title="' . $out . '"' : $out;
}
if ($row['alias']) {
$parts[] = $lang->sL($GLOBALS['TCA']['pages']['columns']['alias']['label']) . ' ' . $row['alias'];
}
if ($row['pid'] < 0) {
$parts[] = 'v#1.' . $row['t3ver_id'];
}
Expand Down Expand Up @@ -1385,9 +1382,6 @@ public static function getRecordIconAltText($row, $table = 'pages')
$ctrl = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
// Uid is added
$out .= 'id=' . $row['uid'];
if ($table === 'pages' && $row['alias']) {
$out .= ' / ' . $row['alias'];
}
if (static::isTableWorkspaceEnabled($table) && $row['pid'] < 0) {
$out .= ' - v#1.' . $row['t3ver_id'];
}
Expand Down
Expand Up @@ -26,7 +26,7 @@
* This is used to suppress the 'slug' field in pseudo site page trees
* when editing page records and to show the alias field.
*
* Both "Pseudo sites" and "alias" db field will bite the dust in TYPO3 v10.0,
* Both "Pseudo sites" will bite the dust in TYPO3 v10.0,
* so this is a temporary display condition for v9 only and thus marked internal.
*
* @internal Implementation and class will probably vanish in TYPO3 v10.0 without further notice
Expand Down
43 changes: 3 additions & 40 deletions typo3/sysext/core/Classes/Database/SoftReferenceIndex.php
Expand Up @@ -15,8 +15,6 @@
*/

use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -428,7 +426,7 @@ public function findRef_extension_fileref($content)
* Analyze content as a TypoLink value and return an array with properties.
* TypoLinks format is: <link [typolink] [browser target] [css class] [title attribute] [additionalParams]>.
* See TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typolink()
* The syntax of the [typolink] part is: [typolink] = [page id or alias][,[type value]][#[anchor, if integer = tt_content uid]]
* The syntax of the [typolink] part is: [typolink] = [page id][,[type value]][#[anchor, if integer = tt_content uid]]
* The extraction is based on how \TYPO3\CMS\Frontend\ContentObject::typolink() behaves.
*
* @param string $typolinkValue TypoLink value.
Expand Down Expand Up @@ -526,16 +524,7 @@ public function getTypoLinkParts($typolinkValue)
$link_param = $pairParts[0];
$finalTagParts['type'] = $pairParts[1]; // Overruling 'type'
}

// Checking if the id-parameter is an alias.
if ((string)$link_param !== '') {
if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($link_param)) {
$finalTagParts['alias'] = $link_param;
$link_param = $this->getPageIdFromAlias($link_param);
}

$finalTagParts['page_id'] = (int)$link_param;
}
$finalTagParts['page_id'] = (int)$link_param;
}

return $finalTagParts;
Expand Down Expand Up @@ -603,7 +592,7 @@ public function setTypoLinkPartsElement($tLP, &$elements, $content, $idx)
'type' => 'db',
'recordRef' => 'pages:' . $tLP['page_id'],
'tokenID' => $tokenID,
'tokenValue' => $tLP['alias'] ? $tLP['alias'] : $tLP['page_id']
'tokenValue' => $tLP['page_id']
];
}
// Add type if applicable
Expand Down Expand Up @@ -660,32 +649,6 @@ public function setTypoLinkPartsElement($tLP, &$elements, $content, $idx)
return $content;
}

/**
* Look up and return page uid for alias
*
* @param string $link_param Page alias string value
* @return int Page uid corresponding to alias value.
*/
public function getPageIdFromAlias($link_param)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
$queryBuilder->getRestrictions()
->removeAll()
->add(GeneralUtility::makeInstance(DeletedRestriction::class))
->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));

$pageUid = $queryBuilder->select('uid')
->from('pages')
->where(
$queryBuilder->expr()->eq('alias', $queryBuilder->createNamedParameter($link_param, \PDO::PARAM_STR))
)
->setMaxResults(1)
->execute()
->fetchColumn(0);

return (int)$pageUid;
}

/**
* Make Token ID for input index.
*
Expand Down
Expand Up @@ -46,7 +46,7 @@ class LegacyLinkNotationConverter
* - "mailto" an email address
* - "url" external URL
* - "file" a local file (checked AFTER getPublicUrl() is called)
* - "page" a page (integer or alias)
* - "page" a page (integer)
*
* Does NOT check if the page exists or the file exists.
*
Expand Down Expand Up @@ -187,13 +187,6 @@ protected function resolvePageRelatedParameters(string $data): array
} else {
$result['pageuid'] = $data;
}

// expect an alias
if (!MathUtility::canBeInterpretedAsInteger($result['pageuid']) && $result['pageuid'] !== 'current') {
$result['pagealias'] = $result['pageuid'];
unset($result['pageuid']);
}

return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/Classes/LinkHandling/LinkService.php
Expand Up @@ -64,7 +64,7 @@ public function __construct()
* - "mailto" an email address
* - "url" external URL
* - "file" a local file (checked AFTER getPublicUrl() is called)
* - "page" a page (integer or alias)
* - "page" a page (integer)
*
* Does NOT check if the page exists or the file exists.
*
Expand Down
11 changes: 1 addition & 10 deletions typo3/sysext/core/Classes/LinkHandling/PageLinkHandler.php
Expand Up @@ -35,12 +35,7 @@ class PageLinkHandler implements LinkHandlingInterface
*/
public function asString(array $parameters): string
{
$urn = $this->baseUrn;
if (isset($parameters['pagealias']) && $parameters['pagealias'] !== 'current') {
$urn .= '?alias=' . $parameters['pagealias'];
} else {
$urn .= '?uid=' . $parameters['pageuid'];
}
$urn = $this->baseUrn . '?uid=' . $parameters['pageuid'];
$urn = rtrim($urn, ':');
// Page type is set and not empty (= "0" in this case means it is not empty)
if (isset($parameters['pagetype']) && strlen((string)$parameters['pagetype']) > 0) {
Expand Down Expand Up @@ -69,10 +64,6 @@ public function resolveHandlerData(array $data): array
$result['pageuid'] = $data['uid'];
unset($data['uid']);
}
if (isset($data['alias'])) {
$result['pagealias'] = $data['alias'];
unset($data['alias']);
}
if (isset($data['type'])) {
$result['pagetype'] = $data['type'];
unset($data['type']);
Expand Down
5 changes: 0 additions & 5 deletions typo3/sysext/core/Classes/Routing/SiteMatcher.php
Expand Up @@ -29,8 +29,6 @@
use TYPO3\CMS\Core\Site\PseudoSiteFinder;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Frontend\Page\PageRepository;

/**
* Returns a site or pseudo-site (with sys_domain records) based on a given request.
Expand Down Expand Up @@ -89,9 +87,6 @@ public function matchRequest(ServerRequestInterface $request): RouteResultInterf

$pageId = $request->getQueryParams()['id'] ?? $request->getParsedBody()['id'] ?? 0;

if (!empty($pageId) && !MathUtility::canBeInterpretedAsInteger($pageId)) {
$pageId = (int)GeneralUtility::makeInstance(PageRepository::class)->getPageIdFromAlias($pageId);
}
// First, check if we have a _GET/_POST parameter for "id", then a site information can be resolved based.
if ($pageId > 0) {
// Loop over the whole rootline without permissions to get the actual site information
Expand Down
1 change: 0 additions & 1 deletion typo3/sysext/core/Classes/Utility/RootlineUtility.php
Expand Up @@ -81,7 +81,6 @@ class RootlineUtility
't3ver_wsid',
't3ver_state',
'title',
'alias',
'nav_title',
'media',
'layout',
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/core/Configuration/DefaultConfiguration.php
Expand Up @@ -1227,7 +1227,7 @@
mod.web_info.fieldDefinitions {
0 {
label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_0
fields = title,uid,slug,alias,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode
fields = title,uid,slug,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode
}
1 {
label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_1
Expand Down
30 changes: 6 additions & 24 deletions typo3/sysext/core/Configuration/TCA/pages.php
Expand Up @@ -61,10 +61,10 @@
'page-contentFromPid-hideinmenu' => 'apps-pagetree-page-content-from-page-hideinmenu',
'default' => 'apps-pagetree-page-default'
],
'searchFields' => 'title,alias,nav_title,subtitle,url,keywords,description,abstract,author,author_email'
'searchFields' => 'title,nav_title,subtitle,url,keywords,description,abstract,author,author_email'
],
'interface' => [
'showRecordFieldList' => 'doktype,title,alias,rowDescription,hidden,starttime,endtime,fe_group,url,target,shortcut,keywords,description,abstract,newUntil,lastUpdated,cache_timeout,cache_tags,backend_layout,backend_layout_next_level',
'showRecordFieldList' => 'doktype,title,rowDescription,hidden,starttime,endtime,fe_group,url,target,shortcut,keywords,description,abstract,newUntil,lastUpdated,cache_timeout,cache_tags,backend_layout,backend_layout_next_level',
'maxDBListItems' => 30,
'maxSingleDBListItems' => 50
],
Expand Down Expand Up @@ -434,24 +434,6 @@
'eval' => 'trim'
]
],
'alias' => [
'exclude' => true,
'displayCond' => [
'AND' => [
'VERSION:IS:false',
'USER:' . \TYPO3\CMS\Core\Compatibility\PseudoSiteTcaDisplayCondition::class . '->isInPseudoSite:pages:true',
],
],
'l10n_mode' => 'exclude',
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.alias',
'config' => [
'type' => 'input',
'size' => 50,
'max' => 32,
'eval' => 'nospace,alphanum_x,lower,unique',
'softref' => 'notify'
]
],
'url' => [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.url',
'config' => [
Expand Down Expand Up @@ -587,7 +569,7 @@
'minitems' => 0,
'suggestOptions' => [
'default' => [
'additionalSearchFields' => 'nav_title, alias, url',
'additionalSearchFields' => 'nav_title, url',
'addWhere' => ' AND pages.uid != ###THIS_UID###'
]
],
Expand Down Expand Up @@ -640,7 +622,7 @@
'minitems' => 0,
'suggestOptions' => [
'default' => [
'additionalSearchFields' => 'nav_title, alias, url',
'additionalSearchFields' => 'nav_title, url',
'addWhere' => ' AND pages.uid != ###THIS_UID###'
]
],
Expand Down Expand Up @@ -1114,7 +1096,7 @@
'showitem' => 'layout, lastUpdated, newUntil, no_search'
],
'3' => [
'showitem' => 'alias, target, cache_timeout, cache_tags'
'showitem' => 'target, cache_timeout, cache_tags'
],
'5' => [
'showitem' => 'author, author_email',
Expand Down Expand Up @@ -1197,7 +1179,7 @@
],
'links' => [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.links',
'showitem' => 'alias;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.alias_formlabel, --linebreak--, target;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.target_formlabel',
'showitem' => 'target;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.target_formlabel',
],
'caching' => [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.caching',
Expand Down
Expand Up @@ -279,6 +279,7 @@ The following PHP class methods that have been previously deprecated for v9 have
* :php:`TYPO3\CMS\Core\Crypto\PasswordHashing\PhpassPasswordHash->setHashCount()`
* :php:`TYPO3\CMS\Core\Crypto\PasswordHashing\PhpassPasswordHash->setMaxHashCount()`
* :php:`TYPO3\CMS\Core\Crypto\PasswordHashing\PhpassPasswordHash->setMinHashCount()`
* :php:`TYPO3\CMS\Core\Database\SoftReferenceIndex->getPageIdFromAlias()`
* :php:`TYPO3\CMS\Core\DataHandling\DataHandler->getTCEMAIN_TSconfig()`
* :php:`TYPO3\CMS\Core\DataHandling\DataHandler->newlog2()`
* :php:`TYPO3\CMS\Core\DataHandling\DataHandler->resorting()`
Expand Down Expand Up @@ -373,6 +374,7 @@ The following PHP class methods that have been previously deprecated for v9 have
* :php:`TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->storeSessionData()`
* :php:`TYPO3\CMS\Frontend\Page\PageRepository->getFirstWebPage()`
* :php:`TYPO3\CMS\Frontend\Page\PageRepository->getDomainStartPage()`
* :php:`TYPO3\CMS\Frontend\Page\PageRepository->getPageIdFromAlias()`
* :php:`TYPO3\CMS\Frontend\Page\PageRepository->getRootLine()`
* :php:`TYPO3\CMS\Frontend\Page\PageRepository->getRecordsByField()`
* :php:`TYPO3\CMS\Frontend\Page\PageRepository->deleteClause()`
Expand Down Expand Up @@ -1059,6 +1061,7 @@ The following database tables have been removed:

The following database fields have been removed:

* `pages.alias`
* `index_phash.data_page_reg1`


Expand Down
Expand Up @@ -109,18 +109,6 @@ pages:fe_group</source>
<trans-unit id="extendToSubpages.image_descr">
<source>This page has access restricted to a certain group and has "Extend to Subpages" set as well. This is reflected in the way the page icon has changed.</source>
</trans-unit>
<trans-unit id="alias.description">
<source>A URL Alias is a unique identification string for a page. You can use this string instead of the ID number to refer to the page.</source>
</trans-unit>
<trans-unit id="alias.details" xml:space="preserve">
<source>Ultimately a page is identified by its ID number. For example, you may access a page in TYPO3 at '.../?id=123'. If the page with ID '123' has the URL Alias 'one_two_three', then the URL '.../?id=one_two_three' would display exactly the same page, because 'one_two_three' is a URL Alias for the ID '123'.
URL Aliases are normally assigned to only the most frequently used pages rather than all pages. In most TYPO3 configurations you would be able to use the syntax '.. &amp;lt;link one_two_three&amp;gt;go to the page&amp;lt;/link&amp;gt; ..' to create a link to the page. This is easier to remember.
Another use is if you need to change which page a commonly used link points to. In this case you can delete the URL Alias for the original page and re-add it on the new page. All links using the URL Alias would now refer to the new page and its ID number.</source>
</trans-unit>
<trans-unit id="alias.syntax" xml:space="preserve">
<source>A URL Alias can contain only lowercase alphanumeric characters and must be unique.
Please note: If the URL Alias already exists in the site, it will have a number added to the end of it.</source>
</trans-unit>
<trans-unit id="target.description">
<source>This sets the default Link Target for menu items linking to this page. Can also used to open the page as a popup window.</source>
</trans-unit>
Expand Down
@@ -1,5 +1,5 @@
"pages",,,,,,,,,,,,
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","alias"
,"uid","pid","sorting","deleted","t3_origuid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_oid","t3ver_move_id","title","keywords"
,1,0,256,0,0,0,0,0,0,0,"FunctionalTest","functional"
,88,1,256,0,0,0,0,0,0,0,"DataHandlerTest","datahandler"
,89,88,256,0,0,0,0,0,0,0,"Relations","relations"
Expand Down

0 comments on commit 24b08ef

Please sign in to comment.