-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Page title starts with a number #707
Comments
|
I think this is a leftover from our long dropped database abstraction layer. I don't see a reason why this should be needed for a page alias and I'm okay with dropping it in 4.4. |
|
I believe that the prefix is added by the https://github.com/contao/core-bundle/blob/master/src/Resources/contao/library/Contao/Model.php#L829 |
|
No I didn't specifically mean anything like this. I just thought there was something like that veeeeery long time ago ;-) |
|
Which we obviously cannot do without breaking BC. |
|
I can't see any BC here. It's just a page alias, page aliases only change when you edit the page. And honestly, I don't know any reason why one would like to have the |
Yes but since HTML5, it's allowed. (http://stackoverflow.com/a/36458675) |
The
Well, then I am fine with removing the |
|
I said remove it in the |
|
How is that supposed to work? We cannot apply |
|
You probably mean adding a third argument to the |
|
Yeah, something like that :) |
|
I think this was also related to finyByIdOrAlias which initially just casted the value to ID, pontentially finding a page ID that does not have that alias.
Should also not be a problem since we added the is_numeric check.
|
|
I had the same problem in Catalog back then. Have written some rather big comment back in the day. It definately was related to searching for numeric ids at the same time as searching for textual aliases. |
|
For the record, my comment is over here. -- returns dataset with id 123
SELECT p.id, p.alias FROM tl_page p WHERE p.id='123';
-- returns dataset with id 123
SELECT p.id, p.alias FROM tl_page p WHERE p.id=123;
-- returns dataset with id 123
SELECT p.id, p.alias FROM tl_page p WHERE p.id='123-testing';
-- returns no dataset
SELECT p.id, p.alias FROM tl_page p WHERE p.id='id-123-testing';As you see, all queries performing something like: SELECT p.id, p.alias FROM tl_page p WHERE p.id='123-testing' OR p.alias='123-testing';Will randomly either return the dataset with ID 123 OR the one with alias 123-testing. |
|
So that's because the db truncates everything that is not a digit and then it matches. Funny. Is that due to the non-strict mode? Anyway, your // Try to load from the registry
if (is_numeric($varId) && empty($arrOptions))
{
$objModel = \Model\Registry::getInstance()->fetch(static::$strTable, $varId);
if ($objModel !== null)
{
return $objModel;
}
}
$t = static::$strTable;
$arrOptions = array_merge
(
array
(
'limit' => 1,
'column' => array("($t.id=? OR $t.alias=?)"),
'value' => array((is_numeric($varId) ? $varId : 0), $varId),
'return' => 'Model'
),
$arrOptions
);
return static::find($arrOptions);But can anybody tell me why the code does an diff --git a/system/modules/core/library/Contao/Model.php b/system/modules/core/library/Contao/Model.php
index 515018f..d855f15 100644
--- a/system/modules/core/library/Contao/Model.php
+++ b/system/modules/core/library/Contao/Model.php
@@ -807,8 +807,10 @@ abstract class Model
*/
public static function findByIdOrAlias($varId, array $arrOptions=array())
{
+ $isAlias = is_numeric($varId);
+
// Try to load from the registry
- if (is_numeric($varId) && empty($arrOptions))
+ if ($isAlias && empty($arrOptions))
{
$objModel = \Model\Registry::getInstance()->fetch(static::$strTable, $varId);
@@ -825,8 +827,8 @@ abstract class Model
array
(
'limit' => 1,
- 'column' => array("($t.id=? OR $t.alias=?)"),
- 'value' => array((is_numeric($varId) ? $varId : 0), $varId),
+ 'column' => $isAlias ? "$t.alias=?" : "$t.id=?",
+ 'value' => $varId,
'return' => 'Model'
), |
|
Probably just for lazyness, it has always been like that. I would be fine changing this.
So an alias can start with a number, but it must never be JUST a number.
|
Exactly. We should keep the |
|
Ok, so I'll adjust the code to allow non-numeric aliases starting with a number. @Toflar Do you want to create a separate ticket/PR to change the |
|
See #729 |
|
Thank you @Toflar. |
|
Fixed in 5ec030b. |
|
I have changed the implementation in f14eaf2 so the logic applies to the |
|
Unfortunately, I don't think that's gonna work. |
|
Which is why we don't have the |
|
But the query change has been assigned to Contao 4.4 (new feature). Do you want me to merge it into version 4.3.6 instead? |
I know, but as said, that only applies to the core things! Extensions might still use the old query mode and rely on |
|
No, this change should be part of 4.4! |
|
Ok, but we can still leave it in the code base, can't we? |
|
Hm, the following does not work on my system: SELECT * FROM tl_page WHERE alias='403-foo';How do I reproduce the initial problem? |
* Make Symfony 3.2 the minimum requirement (see contao#630). * Set the encryption key from the kernel secret by default (see contao#660). * Stop using the deprecated QuestionHelper::setInputStream() method. * Update Dropzone to version 4. * Prefer the caret operator over the tilde operator in the composer.json file. * Add the contao.root_dir parameter (see contao#662). * Update the change log. * Stop using the contao-components/all meta package. * Update the README.md file. * Deprecate the contao:version command (see contao#668). * Update the installation path. * Auto-select the active page in the quick navigation/link module (see contao/core#8587). * Look up the form class and allow to choose the type (see contao/core#8527). * Add PHP Toolbox support (see contao#565). * Remove the arrow brackets in the book navigation template (see contao/core#8607). * Add a bottom padding to the buttons layer. * Add the contao.web_dir parameter (see contao/installation-bundle#40). * Fix the tests. * Match security firewall based on request scope (see contao#677). * Fix an issue found by Scrutinizer. * Use the contao.web_dir parameter in the Combiner (see contao#679). * Fix the tests. * Add stripRootDir() method to System class (see contao#683). * Add the contao.image.target_dir parameter (see contao#684). * The ContaoCoreExtension::overwriteImageTargetDir() is not deprecated. * Support custom backend routes (see contao#512). * Use the scope matcher instead of checking the request attribute (see contao#688). * Replace every occurrence of $contaoFramework with $framework. * Fix an issue found by Scrutinizer. * Fix deprecations in unit tests (see contao#687). * Added a DBAL field type for UUIDs (see contao#415). * Support importing form field options from a CSV field (see contao#444). * Fix the coding style and the unit tests. * Add the Doctrine field type in the config.yml file. doctrine: dbal: types: binary_string: class: "Contao\\CoreBundle\\Doctrine\\DBAL\\Types\\BinaryStringType" commented: true * Add a basic unit test for the BackendCsvImportController class. * Update the change log. * Fix rebuilding the search index (see contao#689). * Also handle „no origin“ and „empty origin“ in the CORS provider. * Remove an unused use statement. * Remove the security.yml file and update the README.md file. * Improve the e-mail extraction in the text element (thanks to Martin Auswöger). * Rename the Test namespace to Tests. * Update the composer.json file. * Update the .php_cs file. * Raise the minimum PHP version to 5.6 (see contao#701). * Support using objects in callback arrays (see contao#699). * Use try-finally blocks to close all output buffers when downloading a file (see contao#714). * Fix the coding style. * Only prefix an all numeric alias when standardizing (see contao#707). * Adjust the test namespaces. * Allow to manually pass a value to any widget (see contao#674). * Add a change log entry and fix the tests. * Disable the picker buttons if the main window does not show a picker. * Use the file manager instead of the file picker. * Use the site structure instead of the page picker. * Always show the selected nodes. * Add the menu builder.
|
See #729. |
When the page title starts with a number, the page alias gets an id in front.
e. g. page title = 1. Contao Konferenz / page alias = id-1-contao-konferenz
Is this behaviour still required or can we left out the id?
The text was updated successfully, but these errors were encountered: