-
-
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
Support checking the registry for table prefixed queries #1161
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works in my use case.
$varKey = is_array($arrOptions['value']) ? $arrOptions['value'][0] : $arrOptions['value']; | ||
$objModel = \Model\Registry::getInstance()->fetch(static::$strTable, $varKey, $arrColumn[0]); | ||
// Support table prefixes | ||
$arrColumn[0] = $result = preg_replace('/^' . preg_quote(static::getTable(), '/') . '\./', '', $arrColumn[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the $result =
part supposed to be there?
@@ -175,6 +175,14 @@ public static function findByUuid($strUuid, array $arrOptions=array()) | |||
$strUuid = \StringUtil::uuidToBin($strUuid); | |||
} | |||
|
|||
// Check in model registry (does not work by default due to UNHEX()) | |||
$objModel = \Model\Registry::getInstance()->fetch(static::$strTable, $strUuid, 'uuid'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to
core-bundle/src/Resources/contao/models/PageModel.php
Lines 660 to 683 in b894c22
public static function findPublishedFallbackByHostname($strHost, array $arrOptions=array()) | |
{ | |
// Try to load from the registry (see #8544) | |
if (empty($arrOptions)) | |
{ | |
$objModel = \Model\Registry::getInstance()->fetch(static::$strTable, $strHost, 'contao.dns-fallback'); | |
if ($objModel !== null) | |
{ | |
return $objModel; | |
} | |
} | |
$t = static::$strTable; | |
$arrColumns = array("$t.dns=? AND $t.fallback='1'"); | |
if (isset($arrOptions['ignoreFePreview']) || !BE_USER_LOGGED_IN) | |
{ | |
$time = \Date::floorToMinute(); | |
$arrColumns[] = "($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'" . ($time + 60) . "') AND $t.published='1'"; | |
} | |
return static::findOneBy($arrColumns, $strHost, $arrOptions); | |
} |
empty($arrOptions)
check here, shouldn't we?
Updated :) |
I wonder if we should backport this to 3.5 as the non usage of the registry could be considered a bug. |
@Toflar What do you think? |
Guess there are arguments for both, pro and contra :-) I‘d be okay with backporting it.
|
Backported in contao/core@36bb1a7. |
Version 3.5.34 (2018-03-06) --------------------------- ### Fixed Check the registry for table prefixed queries (see contao/core-bundle#1161). ### Fixed Improve the folder hashing performance (see #8856). ### Fixed Reset the autologin hash if the username or password changes (see #8843). ### Fixed Correctly encode the sitemap URLs (see #8849).
No description provided.