This repository was archived by the owner on May 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Cleanup page indexer request class #9
Open
markusguenther
wants to merge
3
commits into
TYPO3-extensions:master
Choose a base branch
from
markusguenther:cleanup_pageindexer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,58 +26,58 @@ | |
/** | ||
* Index Queue Page Indexer request with details about which actions to perform. | ||
* | ||
* @author Ingo Renner <[email protected]> | ||
* @package TYPO3 | ||
* @subpackage solr | ||
* @author Ingo Renner <[email protected]> | ||
* @package TYPO3 | ||
* @subpackage solr | ||
*/ | ||
class Tx_Solr_IndexQueue_PageIndexerRequest { | ||
|
||
/** | ||
* List of actions to perform during page rendering. | ||
* | ||
* @var array | ||
* @var array | ||
*/ | ||
protected $actions = array(); | ||
|
||
/** | ||
* Parameters as sent from the Index Queue page indexer. | ||
* | ||
* @var array | ||
* @var array | ||
*/ | ||
protected $parameters = array(); | ||
|
||
/** | ||
* Headers as sent from the Index Queue page indexer. | ||
* | ||
* @var array | ||
* @var array | ||
*/ | ||
protected $header = array(); | ||
|
||
/** | ||
* Unique request ID. | ||
* | ||
* @var string | ||
* @var string | ||
*/ | ||
protected $requestId; | ||
|
||
/** | ||
* Username to use for basic auth protected URLs. | ||
* | ||
* @var string | ||
* @var string | ||
*/ | ||
protected $username = ''; | ||
|
||
/** | ||
* Password to use for basic auth protected URLs. | ||
* | ||
* @var string | ||
* @var string | ||
*/ | ||
protected $password = ''; | ||
|
||
/** | ||
* An Index Queue item related to this request. | ||
* | ||
* @var Tx_Solr_IndexQueue_Item | ||
* @var Tx_Solr_IndexQueue_Item | ||
*/ | ||
protected $indexQueueItem = NULL; | ||
|
||
|
@@ -91,7 +91,7 @@ class Tx_Solr_IndexQueue_PageIndexerRequest { | |
/** | ||
* Constructor for Tx_Solr_IndexQueue_PageIndexerRequest | ||
* | ||
* @param string $header JSON encoded Index Queue page indexer parameters | ||
* @param string $header JSON encoded Index Queue page indexer parameters | ||
*/ | ||
public function __construct($header = NULL) { | ||
$this->requestId = uniqid(); | ||
|
@@ -116,11 +116,11 @@ public function __construct($header = NULL) { | |
/** | ||
* Executes the request. | ||
* | ||
* Uses headers to submit additonal data and avoiding to have these | ||
* Uses headers to submit additional data and avoiding to have these | ||
* arguments integrated into the URL when created by RealURL. | ||
* | ||
* @param string $url The URL to request. | ||
* @return Tx_Solr_IndexQueue_PageIndexerResponse Response | ||
* @param string $url The URL to request. | ||
* @return Tx_Solr_IndexQueue_PageIndexerResponse Response | ||
*/ | ||
public function send($url) { | ||
$headers = $this->getHeaders(); | ||
|
@@ -141,7 +141,7 @@ public function send($url) { | |
) | ||
)); | ||
|
||
$rawResponse = file_get_contents($url, FALSE, $context); | ||
$rawResponse = @file_get_contents($url, FALSE, $context); | ||
|
||
// convert JSON response to response object properties | ||
$decodedResponse = $response->getResultsFromJson($rawResponse); | ||
|
@@ -196,7 +196,7 @@ public function addHeader($header) { | |
/** | ||
* Generates the headers to be send with the request. | ||
* | ||
* @return array Array of HTTP headers. | ||
* @return array Array of HTTP headers. | ||
*/ | ||
public function getHeaders() { | ||
$headers = $this->header; | ||
|
@@ -209,7 +209,6 @@ public function getHeaders() { | |
'actions' => implode(',', $this->actions), | ||
'hash' => md5( | ||
$itemId . '|' . | ||
$pageId . '|' . | ||
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you're also removing the pipe, which likely leads to a hash mismatch. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean this is a problem if you upgrade ... but if you have a clean index it should be fine. |
||
) | ||
); | ||
|
@@ -230,7 +229,7 @@ public function getHeaders() { | |
* Checks whether this is a legitimate request coming from the Index Queue | ||
* page indexer worker task. | ||
* | ||
* @return boolean TRUE if it's a legitimate request, FALSE otherwise. | ||
* @return boolean TRUE if it's a legitimate request, FALSE otherwise. | ||
*/ | ||
public function isAuthenticated() { | ||
$authenticated = FALSE; | ||
|
@@ -253,7 +252,7 @@ public function isAuthenticated() { | |
/** | ||
* Adds an action to perform during page rendering. | ||
* | ||
* @param string $action Action name. | ||
* @param string $action Action name. | ||
*/ | ||
public function addAction($action) { | ||
$this->actions[] = $action; | ||
|
@@ -262,7 +261,7 @@ public function addAction($action) { | |
/** | ||
* Gets the list of actions to perform during page rendering. | ||
* | ||
* @return array List of actions | ||
* @return array List of actions | ||
*/ | ||
public function getActions() { | ||
return $this->actions; | ||
|
@@ -271,7 +270,7 @@ public function getActions() { | |
/** | ||
* Gets the request's parameters. | ||
* | ||
* @return array Request parameters. | ||
* @return array Request parameters. | ||
*/ | ||
public function getParameters() { | ||
return $this->parameters; | ||
|
@@ -280,7 +279,7 @@ public function getParameters() { | |
/** | ||
* Gets the request's unique ID. | ||
* | ||
* @return string Unique request ID. | ||
* @return string Unique request ID. | ||
*/ | ||
public function getRequestId() { | ||
return $this->requestId; | ||
|
@@ -289,8 +288,8 @@ public function getRequestId() { | |
/** | ||
* Gets a specific parameter's value. | ||
* | ||
* @param string $parameterName The parameter to retrieve. | ||
* @return mixed NULL if a parameter was not set or it's value otherwise. | ||
* @param string $parameterName The parameter to retrieve. | ||
* @return mixed NULL if a parameter was not set or it's value otherwise. | ||
*/ | ||
public function getParameter($parameterName) { | ||
$value = NULL; | ||
|
@@ -305,8 +304,9 @@ public function getParameter($parameterName) { | |
/** | ||
* Sets a request's parameter and its value. | ||
* | ||
* @param string $parameter Parameter name | ||
* @param mixed $value Parameter value. | ||
* @param string $parameter Parameter name | ||
* @param mixed $value Parameter value. | ||
* @return void | ||
*/ | ||
public function setParameter($parameter, $value) { | ||
if (is_bool($value)) { | ||
|
@@ -319,8 +319,9 @@ public function setParameter($parameter, $value) { | |
/** | ||
* Sets username and password to be used for a basic auth request header. | ||
* | ||
* @param string $username username. | ||
* @param string $password password. | ||
* @param string $username username. | ||
* @param string $password password. | ||
* @return void | ||
*/ | ||
public function setAuthorizationCredentials($username, $password) { | ||
$this->username = $username; | ||
|
@@ -331,6 +332,7 @@ public function setAuthorizationCredentials($username, $password) { | |
* Sets the Index Queue item this request is related to. | ||
* | ||
* @param Tx_Solr_IndexQueue_Item $item Related Index Queue item. | ||
* @return void | ||
*/ | ||
public function setIndexQueueItem(Tx_Solr_IndexQueue_Item $item) { | ||
$this->indexQueueItem = $item; | ||
|
@@ -355,7 +357,7 @@ public function setTimeout($timeout) { | |
} | ||
} | ||
|
||
if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/solr/Classes/IndexQueue/PageIndexerRequest.php']) { | ||
if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/solr/Classes/IndexQueue/PageIndexerRequest.php']) { | ||
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/solr/Classes/IndexQueue/PageIndexerRequest.php']); | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't use the @ silencer
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.
But in this case you will get warnings in the backend and this is also not so nice ... you will see the error later in the backend module or devlog.