BUG 9180 Replace json_decode function by G::json_decode
Replace json_decode function by G::json_decode to support PHP versions without json support configured.
This commit is contained in:
@@ -37,7 +37,6 @@ require_once "entities/AppSolrQueue.php";
|
|||||||
require_once "classes/model/AppSolrQueue.php";
|
require_once "classes/model/AppSolrQueue.php";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalid search text for Solr exception
|
* Invalid search text for Solr exception
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -116,11 +116,11 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
$removeCondition = str_replace ($value, '', $facetRequestEntity->selectedFacetsString, $count);
|
$removeCondition = str_replace ($value, '', $facetRequestEntity->selectedFacetsString, $count);
|
||||||
}
|
}
|
||||||
$selectedFacetGroupData = array (
|
$selectedFacetGroupData = array (
|
||||||
'selectedFacetGroupName' => $gr [0],
|
'selectedFacetGroupName' => $gr [0],
|
||||||
'selectedFacetGroupPrintName' => $gr [1],
|
'selectedFacetGroupPrintName' => $gr [1],
|
||||||
'selectedFacetItemName' => $it [0],
|
'selectedFacetItemName' => $it [0],
|
||||||
'selectedFacetItemPrintName' => $it [1],
|
'selectedFacetItemPrintName' => $it [1],
|
||||||
'selectedFacetRemoveCondition' => $removeCondition
|
'selectedFacetRemoveCondition' => $removeCondition
|
||||||
);
|
);
|
||||||
|
|
||||||
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
|
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
|
||||||
@@ -159,9 +159,9 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
// create list of facets
|
// create list of facets
|
||||||
$facetsList = $solr->getFacetsList ($facetRequestEntity);
|
$facetsList = $solr->getFacetsList ($facetRequestEntity);
|
||||||
|
|
||||||
$numFound = $facetsList ['response'] ['numFound'];
|
$numFound = $facetsList->response->numFound;
|
||||||
|
|
||||||
$facetCounts = $facetsList ['facet_counts'];
|
$facetCounts = $facetsList->facet_counts;
|
||||||
|
|
||||||
$facetGroups = array ();
|
$facetGroups = array ();
|
||||||
// convert facet fields result to objects
|
// convert facet fields result to objects
|
||||||
@@ -169,7 +169,7 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
* *********************************************************************
|
* *********************************************************************
|
||||||
*/
|
*/
|
||||||
// include facet field results
|
// include facet field results
|
||||||
$facetFieldsResult = $facetsList ['facet_counts'] ['facet_fields'];
|
$facetFieldsResult = $facetsList->facet_counts->facet_fields;
|
||||||
if (! empty ($facetFieldsResult)) {
|
if (! empty ($facetFieldsResult)) {
|
||||||
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
||||||
if (count ($facetvalues) > 0) // if the group have facets included
|
if (count ($facetvalues) > 0) // if the group have facets included
|
||||||
@@ -200,10 +200,10 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
* *********************************************************************
|
* *********************************************************************
|
||||||
*/
|
*/
|
||||||
// include facet date ranges results
|
// include facet date ranges results
|
||||||
$facetDatesResult = $facetsList ['facet_counts'] ['facet_dates'];
|
$facetDatesResult = $facetsList->facet_counts->facet_dates;
|
||||||
if (! empty ($facetDatesResult)) {
|
if (! empty ($facetDatesResult)) {
|
||||||
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
||||||
if (count ($facetvalues) > 3) // if the group have any facets included
|
if (count ((array)$facetvalues) > 3) // if the group have any facets included
|
||||||
// besides start, end and gap
|
// besides start, end and gap
|
||||||
{
|
{
|
||||||
$data = array (
|
$data = array (
|
||||||
@@ -212,7 +212,7 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
$data ['facetGroupPrintName'] = $facetGroup;
|
$data ['facetGroupPrintName'] = $facetGroup;
|
||||||
$data ['facetGroupType'] = 'daterange';
|
$data ['facetGroupType'] = 'daterange';
|
||||||
$facetItems = array ();
|
$facetItems = array ();
|
||||||
$facetvalueskeys = array_keys ($facetvalues);
|
$facetvalueskeys = array_keys ((array)$facetvalues);
|
||||||
foreach ($facetvalueskeys as $i => $k) {
|
foreach ($facetvalueskeys as $i => $k) {
|
||||||
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
||||||
$dataItem = array ();
|
$dataItem = array ();
|
||||||
@@ -223,11 +223,11 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// the last group
|
// the last group
|
||||||
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues ['end'] . ']';
|
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||||
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues ['end'] . ']';
|
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
$dataItem ['facetCount'] = $facetvalues [$k];
|
$dataItem ['facetCount'] = $facetvalues->$k;
|
||||||
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||||
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
|
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
|
||||||
$facetItems [] = $newFacetItem;
|
$facetItems [] = $newFacetItem;
|
||||||
@@ -339,12 +339,9 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
public function getDataTablePaginatedList($solrRequestData)
|
public function getDataTablePaginatedList($solrRequestData)
|
||||||
{
|
{
|
||||||
require_once ('class.solr.php');
|
require_once ('class.solr.php');
|
||||||
// require_once (ROOT_PATH .
|
|
||||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
|
||||||
require_once ('entities/SolrRequestData.php');
|
require_once ('entities/SolrRequestData.php');
|
||||||
require_once ('entities/SolrQueryResult.php');
|
require_once ('entities/SolrQueryResult.php');
|
||||||
|
|
||||||
// print_r($solrRequestData);
|
|
||||||
// prepare the list of sorted columns
|
// prepare the list of sorted columns
|
||||||
// verify if the data of sorting is available
|
// verify if the data of sorting is available
|
||||||
if (isset ($solrRequestData->sortCols [0])) {
|
if (isset ($solrRequestData->sortCols [0])) {
|
||||||
@@ -363,7 +360,6 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
|
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
|
||||||
// array(''));
|
// array(''));
|
||||||
|
|
||||||
// print_r($solrRequestData);
|
|
||||||
// execute query
|
// execute query
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||||
$solrPaginatedResult = $solr->executeQuery ($solrRequestData);
|
$solrPaginatedResult = $solr->executeQuery ($solrRequestData);
|
||||||
@@ -372,9 +368,9 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
$numTotalDocs = $solr->getNumberDocuments ($solrRequestData->workspace);
|
$numTotalDocs = $solr->getNumberDocuments ($solrRequestData->workspace);
|
||||||
|
|
||||||
// create the Datatable response of the query
|
// create the Datatable response of the query
|
||||||
$numFound = $solrPaginatedResult ['response'] ['numFound'];
|
$numFound = $solrPaginatedResult->response->numFound;
|
||||||
|
|
||||||
$docs = $solrPaginatedResult ['response'] ['docs'];
|
$docs = $solrPaginatedResult->response->docs;
|
||||||
// print_r($docs);
|
// print_r($docs);
|
||||||
// insert list of names in docs result
|
// insert list of names in docs result
|
||||||
$data = array (
|
$data = array (
|
||||||
@@ -393,8 +389,8 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
$data ['aaData'] [$i] [] = ''; // placeholder
|
$data ['aaData'] [$i] [] = ''; // placeholder
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isset ($doc [$columnName])) {
|
if (isset ($doc->$columnName)) {
|
||||||
$data ['aaData'] [$i] [] = $doc [$columnName];
|
$data ['aaData'] [$i] [] = $doc->$columnName;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$data ['aaData'] [$i] [] = '';
|
$data ['aaData'] [$i] [] = '';
|
||||||
@@ -416,27 +412,19 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
*/
|
*/
|
||||||
public function getIndexFields($workspace)
|
public function getIndexFields($workspace)
|
||||||
{
|
{
|
||||||
// global $indexFields;
|
|
||||||
// cache
|
|
||||||
// if(!empty($indexFields))
|
|
||||||
// return $indexFields;
|
|
||||||
|
|
||||||
require_once ('class.solr.php');
|
require_once ('class.solr.php');
|
||||||
// require_once (ROOT_PATH .
|
|
||||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||||
|
|
||||||
// print "SearchIndex!!!!";
|
// print "SearchIndex!!!!";
|
||||||
// create list of facets
|
// create list of facets
|
||||||
$solrFieldsData = $solr->getListIndexedStoredFields ($workspace);
|
$solrFieldsData = $solr->getListIndexedStoredFields ($workspace);
|
||||||
|
|
||||||
// copy list of arrays
|
// copy list of arrays
|
||||||
$listFields = array ();
|
$listFields = array ();
|
||||||
foreach ($solrFieldsData ['fields'] as $key => $fieldData) {
|
foreach ($solrFieldsData->fields as $key => $fieldData) {
|
||||||
if (array_key_exists ('dynamicBase', $fieldData)) {
|
if (array_key_exists ('dynamicBase', $fieldData)) {
|
||||||
// remove *
|
$originalFieldName = substr ($key, 0, - strlen ($fieldData->dynamicBase) + 1);
|
||||||
$originalFieldName = substr ($key, 0, - strlen ($fieldData ['dynamicBase']) + 1);
|
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
||||||
// $listFields[strtolower($originalFieldName)] = $key;
|
|
||||||
// Maintain case sensitive variable names
|
// Maintain case sensitive variable names
|
||||||
$listFields [$originalFieldName] = $key;
|
$listFields [$originalFieldName] = $key;
|
||||||
}
|
}
|
||||||
@@ -447,9 +435,6 @@ class BpmnEngine_Services_SearchIndex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// print_r($listFields);
|
|
||||||
// $indexFields = $listFields;
|
|
||||||
|
|
||||||
return $listFields;
|
return $listFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ class BpmnEngine_SearchIndexAccess_Solr
|
|||||||
curl_close ($handlerTotal);
|
curl_close ($handlerTotal);
|
||||||
|
|
||||||
// verify the result of solr
|
// verify the result of solr
|
||||||
$responseSolrTotal = G::json_decode ($responseTotal, true);
|
$responseSolrTotal = G::json_decode ($responseTotal);
|
||||||
if ($responseSolrTotal ['responseHeader'] ['status'] != 0) {
|
if ($responseSolrTotal->responseHeader->status != 0) {
|
||||||
throw new Exception ("Error returning the total number of documents in Solr." . $solrIntruct);
|
throw new Exception ("Error returning the total number of documents in Solr." . $solrIntruct);
|
||||||
}
|
}
|
||||||
$numTotalDocs = $responseSolrTotal ['response'] ['numFound'];
|
$numTotalDocs = $responseSolrTotal->response->numFound;
|
||||||
return $numTotalDocs;
|
return $numTotalDocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,8 +154,8 @@ class BpmnEngine_SearchIndexAccess_Solr
|
|||||||
curl_close ($handler);
|
curl_close ($handler);
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
$responseSolr = G::json_decode ($response, true);
|
$responseSolr = G::json_decode ($response);
|
||||||
if ($responseSolr ['responseHeader'] ['status'] != 0) {
|
if ($responseSolr->responseHeader->status != 0) {
|
||||||
throw new Exception ("Error executing query to Solr." . $solrIntruct);
|
throw new Exception ("Error executing query to Solr." . $solrIntruct);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,8 +324,8 @@ class BpmnEngine_SearchIndexAccess_Solr
|
|||||||
$response = curl_exec ($handler);
|
$response = curl_exec ($handler);
|
||||||
curl_close ($handler);
|
curl_close ($handler);
|
||||||
// decode
|
// decode
|
||||||
$responseSolr = G::json_decode ($response, true);
|
$responseSolr = G::json_decode ($response);
|
||||||
if ($responseSolr ['responseHeader'] ['status'] != 0) {
|
if ($responseSolr->responseHeader->status != 0) {
|
||||||
throw new Exception ("Error getting index fields in Solr." . $solrIntruct);
|
throw new Exception ("Error getting index fields in Solr." . $solrIntruct);
|
||||||
}
|
}
|
||||||
return $responseSolr;
|
return $responseSolr;
|
||||||
@@ -470,8 +470,8 @@ class BpmnEngine_SearchIndexAccess_Solr
|
|||||||
curl_close ($handler);
|
curl_close ($handler);
|
||||||
|
|
||||||
// decode
|
// decode
|
||||||
$responseSolr = G::json_decode ($response, true);
|
$responseSolr = G::json_decode ($response);
|
||||||
if ($responseSolr ['responseHeader'] ['status'] != 0) {
|
if ($responseSolr->responseHeader->status != 0) {
|
||||||
throw new Exception ("Error getting faceted list from Solr." . $solrIntruct);
|
throw new Exception ("Error getting faceted list from Solr." . $solrIntruct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user