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
[!!!][TASK] Allow to disable siteHash check by setting query.allowedSites to * #929
[!!!][TASK] Allow to disable siteHash check by setting query.allowedSites to * #929
Conversation
ab09be1
to
4bbdd8e
Compare
*/ | ||
public function getAllowedSitesForPageIdAndAllowedSitesConfiguration($pageId, $allowedSitesConfiguration) | ||
{ | ||
if ($allowedSitesConfiguration == '__all') { |
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.
Use strict ===
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.
Done
return $siteHashes[$domain]; | ||
} | ||
|
||
$siteHashes[$domain] = sha1($domain . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . 'tx_solr'); |
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.
:-)
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.
Just moved, the hash should be the same as before
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2010-2017 Timo Hund <timo.hund@dkd.de |
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.
If new file 2017- and missing >
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.
Done
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2010-2017 Timo Hund <timo.hund@dkd.de |
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.
If new file 2017 and agin missing >
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.
Done
} | ||
|
||
/** | ||
* Retrieves the domain of the site that belongs to the passed pageId and replaces ther markers __solr_current_site |
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.
their?
* | ||
* @param $pageId | ||
* @param $allowedSitesConfiguration | ||
* @return mixed |
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 it mixed or string as return type?
* @param integer $uid | ||
* @return string | ||
*/ | ||
protected function applyHook($variantId, $systemHash, $type, $uid) |
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.
Maybe it would be better to use the new Signal concept in TYPO3? - I think hooks are only kept for compatibility
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.
signals don't work for every scenario. If you want to change data, you still need hooks.
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.
Not convinced - see https://usetypo3.com/signals-and-hooks-in-typo3.html and https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Documentation/Changelog/master/Feature-79387-AddSignalToExcludeTablesFromReferenceIndex.rst - or have I missed something in this method?
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.
I think signals and slots are more like "events" and the intension is normally a one way direction. It is possible to return data, but only by passing a variable by reference (what is not optimal i would say). I think with hooks you can directly return a value, what is needed in this case (Add btw. in the changes of the core also new hooks are added).
*/ | ||
protected function getSystemHash() | ||
{ | ||
$siteName = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']) ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] : 'none'; |
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.
Im not sure TYPO3 works with this $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] - but I think I would throw an exception instead
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.
I'll propose to throw an exception when sitename is not set.
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.
LGTM, pending minor changes.
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2016 Timo Hund <timo.hund@dkd.de> |
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.
$year++
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.
Done
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'testKey'; | ||
|
||
$service = new SiteHashService(); | ||
$hash1 = $service->getSiteHashForDomain('www.test.de'); |
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.
Please use www.example.com
for such use-cases. test.de
is Stiftung Warentest.
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.
Done
9a6c08b
to
c1e535b
Compare
…ites to * This PR changes the behaviour of query.allowedSites the previos setting * behaviour was changed: * Before: * was the same as __all, which means all sites in the system * After: __all is still handled as __all sites in the system, but * now means every site (same as no check at all) Migration: When you are using * for query.allowedSites change the setting to __all. During the implementation the following things have been done * Move SiteHash related logic from Util* to SiteHashService* and make them non static (See: http://wiki.c2.com/?AbuseOfUtilityClasses) * Mark SiteHash related method in Util deprecated and announce removal * Added Tests for Query and SiteHashService modifications * When variants should be used accross multiple instances the variantId needs to be unique by system (not by site!). By now the variantId only contains (type/uid), to have a unique variantId accros multiple systems, a system hash was added. Impact: * If you use * for query.allowedSites please use __all now unless you want to disable the siteHash check * If you use variants, it is recommended to reindex your pages, since the hash was changed. Fixes: TYPO3-Solr#862
c1e535b
to
2d2c141
Compare
This PR changes the behaviour of
query.allowedSites
; the behavior*
has been changed:*
was the same as__all
, which means all sites in the system__all
is still handled as__all
sites in the system, but*
now means every site (same as no check at all)Implementation Details
During the implementation the following things have been done
variantId
needs to be unique by system (not by site!). As of now thevariantId
only contains (type/uid), to have a uniquevariantId
across multiple systems, a system hash was added.Impact & Migration
*
for query.allowedSites please use__all
now unless you want to disable the siteHash checkFixes: #862