Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Avoids deprecated preg_replace e option
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoslado committed Oct 5, 2015
1 parent 64cb35d commit a2f395a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
14 changes: 12 additions & 2 deletions dfTools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,18 @@ public static function truncateText($text, $length)
public static function stripHtml($text)
{
$text = html_entity_decode($text, ENT_QUOTES, "ISO-8859-1");
$text = preg_replace('/&#(\d+);/me',"chr(\\1)",$text); // decimal notation
$text = preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)",$text); // hex notation
$text = preg_replace_callback(
'/&#(\d+);/mu',
function($matches){
return chr($matches[1]);
},
$text); // decimal notation
$text = preg_replace_callback(
'/&#x([a-f0-9]+);/miu',
function($matches){
return chr('0x'.$matches[1]);
},
$text); // hex notation
$text = str_replace("><", "> <", $text);
$text = preg_replace('/\<br(\s*)?\/?\>/i', " ", $text);
$text = strip_tags($text);
Expand Down
2 changes: 1 addition & 1 deletion doofinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ public function searchOnApi($string,$page=1,$page_size=12,$timeout=8000){

$product_pool_attributes = implode(',', $product_pool_attributes);

if (!$context)
if (!isset($context) || !$context)
$context = Context::getContext();

$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
Expand Down
10 changes: 6 additions & 4 deletions lib/doofinder_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,13 @@ public function query($query=null, $page=null, $options = array()){

$params = $this->search_options;

// translate filters
foreach($params['filter'] as $filterName => $filterValue){
$params['filter'][$filterName] = $this->translateFilter($filterValue);
if(isset($params['filter'])){
// translate filters
foreach($params['filter'] as $filterName => $filterValue){
$params['filter'][$filterName] = $this->translateFilter($filterValue);
}
}

// no query? then match all documents
if(!$this->optionExists('query') || !trim($this->search_options['query'])){
$params['query_name'] = 'match_all';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doofinder-for-prestashop",
"version": "2.0.0",
"version": "2.0.1",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.5.0",
Expand Down

0 comments on commit a2f395a

Please sign in to comment.