Skip to content
This repository was archived by the owner on May 4, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions Classes/IndexQueue/PageIndexerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -141,7 +141,7 @@ public function send($url) {
)
));

$rawResponse = file_get_contents($url, FALSE, $context);
$rawResponse = @file_get_contents($url, FALSE, $context);
Copy link
Contributor

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

Copy link
Author

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.


// convert JSON response to response object properties
$decodedResponse = $response->getResultsFromJson($rawResponse);
Expand Down Expand Up @@ -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;
Expand All @@ -209,7 +209,6 @@ public function getHeaders() {
'actions' => implode(',', $this->actions),
'hash' => md5(
$itemId . '|' .
$pageId . '|' .
$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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.

)
);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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)) {
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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']);
}

Expand Down