Skip to content

Commit

Permalink
Merge pull request #345 from tyrant88/tyrant88-patch-96
Browse files Browse the repository at this point in the history
more Fixes (most in plot and simple dom) for PHP 8.1
  • Loading branch information
tyrant88 authored Aug 17, 2022
2 parents 54caa41 + 6b4fe3c commit fe7cd68
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 40 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## Version 6.9.4 (2022-08-17)
- Fixes for PHP 8.1 thx @skerbis

## Version 6.9.3 (2022-08-16)
- Fix autoreindex on yform change for PHP 8.1 (#337) thx @gharlan

Expand Down
16 changes: 10 additions & 6 deletions lib/search_it.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,12 @@ public function indexArticle($_id, $_clang = false)


try {
if (substr(rex_addon::get('search_it')->getConfig('index_host'),0,1) == ':') {
$scanparts['port'] = trim(rex_addon::get('search_it')->getConfig('index_host'),':');
$index_host = rex_addon::get('search_it')->getConfig('index_host');
if (!isset($index_host)) { $index_host = ''; }
if (substr($index_host,0,1) == ':') {
$scanparts['port'] = trim($index_host,':');
} else {
$scanparts = parse_url(rex_addon::get('search_it')->getConfig('index_host'));
$scanparts = parse_url($index_host);
}

if(rex_addon::get("yrewrite") && rex_addon::get("yrewrite")->isAvailable() && !isset($scanparts['host'])) {
Expand Down Expand Up @@ -421,10 +423,12 @@ public function indexURL($url_hash, $article_id, $clang_id, $profile_id, $data_i
} else if (is_object($article) AND ($article->isOnline() OR rex_addon::get('search_it')->getConfig('indexoffline'))) {
try {

if (substr(rex_addon::get('search_it')->getConfig('index_host'),0,1) == ':') {
$scanparts['port'] = trim(rex_addon::get('search_it')->getConfig('index_host'),':');
$index_host = rex_addon::get('search_it')->getConfig('index_host');
if (!isset($index_host)) { $index_host = ''; }
if (substr($index_host,0,1) == ':') {
$scanparts['port'] = trim($index_host,':');
} else {
$scanparts = parse_url(rex_addon::get('search_it')->getConfig('index_host'));
$scanparts = parse_url($index_host);
}

if(rex_addon::get("yrewrite") && rex_addon::get('yrewrite')->isAvailable() && !isset($scanparts['host'])) {
Expand Down
4 changes: 2 additions & 2 deletions package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: search_it
version: '6.9.3'
version: '6.9.4'
author: Friends Of REDAXO
supportpage: https://github.com/FriendsOfREDAXO/search_it

Expand All @@ -26,7 +26,7 @@ console_commands:
search_it:reindex: rex_search_it_command_reindex

requires:
redaxo: '^5.5.0'
redaxo: '^5.6.0'
php: '>=7'

system_plugins:
Expand Down
2 changes: 1 addition & 1 deletion plugins/autocomplete/package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: search_it/autocomplete
version: '6.9.3'
version: '6.9.4'
author: Manétage

title: 'translate:search_it_autocomplete_plugin_title'
Expand Down
2 changes: 1 addition & 1 deletion plugins/documentation/package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: search_it/documentation
version: '6.9.3'
version: '6.9.4'
author: Friends Of REDAXO

title: 'translate:search_it_documentation_title'
Expand Down
36 changes: 21 additions & 15 deletions plugins/plaintext/lib/simple_html_dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Licensed under The MIT License
Redistributions of files must retain the above copyright notice.
Edited by Robert Rupf: Added the remove-method, which allows to remove nodes in
Edited by Robert Rupf: Added the remove-method, which allows to remove nodes in
the same way you can find them.
Edited by Norbert Micheel: adapted the regex pattern for pcre2 PHP 7.3 in function parse_selector
Expand Down Expand Up @@ -116,7 +116,7 @@ function clear() {
$this->parent = null;
$this->children = null;
}

// dump node's tree
function dump($show_attr=true) {
dump_html_tree($this, $show_attr);
Expand Down Expand Up @@ -146,7 +146,7 @@ function last_child() {
return null;
}

// returns the next sibling of node
// returns the next sibling of node
function next_sibling() {
if ($this->parent===null) return null;
$idx = 0;
Expand Down Expand Up @@ -223,7 +223,7 @@ function text() {
$ret .= $n->text().' ';
return $ret;
}

function xmltext() {
$ret = $this->innertext();
$ret = str_ireplace('<![CDATA[', '', $ret);
Expand Down Expand Up @@ -319,7 +319,7 @@ function find($selector, $idx=null) {
return;
}
}
}
}
return;
}

Expand Down Expand Up @@ -411,7 +411,10 @@ function find($selector, $idx=null) {
if(!empty($m[6])) {$val=$m[6];}

// convert to lowercase
if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
if ($this->dom->lowercase) {
$tag = is_null($tag) ? '' : strtolower($tag);
$key = is_null($key) ? '' : strtolower($key);
}
//elements that do NOT have the specified attribute
if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}

Expand Down Expand Up @@ -445,7 +448,7 @@ function __set($name, $value) {
return $this->_[HDOM_INFO_INNER] = $value;
}
if (!isset($this->attr[$name])) {
$this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
$this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
$this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
}
$this->attr[$name] = $value;
Expand Down Expand Up @@ -482,8 +485,8 @@ function firstChild() {return $this->first_child();}
function lastChild() {return $this->last_child();}
function nextSibling() {return $this->next_sibling();}
function previousSibling() {return $this->prev_sibling();}


// Added by Robert Rupf
// remove elements by css selector
function remove($selector) {
Expand Down Expand Up @@ -555,11 +558,11 @@ class simple_html_dom {
'p'=>array('p'=>1),
'nobr'=>array('nobr'=>1),
);

function __construct($str=null) {
if ($str) {
if (preg_match("/^http:\/\//i",$str) || is_file($str))
$this->load_file($str);
if (preg_match("/^http:\/\//i",$str) || is_file($str))
$this->load_file($str);
else
$this->load($str);
}
Expand Down Expand Up @@ -632,7 +635,7 @@ function clear() {
unset($this->doc);
unset($this->noise);
}

function dump($show_attr=true) {
$this->root->dump($show_attr);
}
Expand Down Expand Up @@ -907,11 +910,13 @@ function dump($show_attr=true) {
}

/*protected*/ function skip($chars) {
if (!isset($chars)) { $chars = ''; }
$this->pos += strspn($this->doc, $chars, $this->pos);
$this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
}

/*protected*/ function copy_skip($chars) {
if (!isset($chars)) { $chars = ''; }
$pos = $this->pos;
$len = strspn($this->doc, $chars, $pos);
$this->pos += $len;
Expand All @@ -921,6 +926,7 @@ function dump($show_attr=true) {
}

/*protected*/ function copy_until($chars) {
if (!isset($chars)) { $chars = ''; }
$pos = $this->pos;
$len = strcspn($this->doc, $chars, $pos);
$this->pos += $len;
Expand Down Expand Up @@ -1018,8 +1024,8 @@ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
function getElementByTagName($name) {return $this->find($name, 0);}
function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
function loadFile() {$args = func_get_args();$this->load(call_user_func_array('file_get_contents', $args), true);}


// Added by Robert Rupf
// remove dom node by css selector
function remove($selector) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/plaintext/package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: search_it/plaintext
version: '6.9.3'
version: '6.9.4'
author: Friends Of REDAXO

title: 'translate:search_it_plaintext_title'
Expand Down
48 changes: 35 additions & 13 deletions plugins/stats/images/phplot/phplot.php
Original file line number Diff line number Diff line change
Expand Up @@ -6826,8 +6826,8 @@ protected function DrawLegend()
$this->DrawText('legend', 0, $x_pos, $yc, $this->ndx_legend_text_color, $leg,
$this->legend_text_align, 'center');
if ($colorbox_mode) {
$y1 = $y_pos - $dot_height + 1;
$y2 = $y_pos - 1;
$y1 = floor($y_pos - $dot_height) + 1;
$y2 = floor($y_pos) - 1;

// If plot area background is on, draw a background for any non-box shapes:
if ($this->draw_plot_area_background && $colorbox_mode != 'box') {
Expand Down Expand Up @@ -7004,6 +7004,26 @@ protected function GetGridSetting($xy)
return isset($this->draw_y_grid) ? $this->draw_y_grid : !$this->datatype_swapped_xy;
}

/**
* @param GdImage|resource $image
* @param array $points
* @param int $numPoints
* @param int $color
* @return void
*/
protected function imageFilledPolygonWrapper(
$image,
array $points,
$numPoints,
$color
) {
if (version_compare(PHP_VERSION, '8.1.0') === -1) {
imagefilledpolygon($image, $points, $numPoints, $color);
} else {
imagefilledpolygon($image, $points, $color);
}
}

/**
* Draws a single marker shape (a dot or shape)
*
Expand Down Expand Up @@ -7054,23 +7074,23 @@ protected function DrawShape($x, $y, $record, $color, $allow_none = TRUE)
break;
case 'diamond':
$arrpoints = array($x1, $y, $x, $y1, $x2, $y, $x, $y2);
ImageFilledPolygon($this->img, $arrpoints, 4, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 4, $color);
break;
case 'triangle':
$arrpoints = array($x1, $y, $x2, $y, $x, $y2);
ImageFilledPolygon($this->img, $arrpoints, 3, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 3, $color);
break;
case 'trianglemid':
$arrpoints = array($x1, $y1, $x2, $y1, $x, $y);
ImageFilledPolygon($this->img, $arrpoints, 3, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 3, $color);
break;
case 'yield':
$arrpoints = array($x1, $y1, $x2, $y1, $x, $y2);
ImageFilledPolygon($this->img, $arrpoints, 3, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 3, $color);
break;
case 'delta':
$arrpoints = array($x1, $y2, $x2, $y2, $x, $y1);
ImageFilledPolygon($this->img, $arrpoints, 3, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 3, $color);
break;
case 'star':
ImageLine($this->img, $x1, $y, $x2, $y, $color);
Expand All @@ -7080,11 +7100,11 @@ protected function DrawShape($x, $y, $record, $color, $allow_none = TRUE)
break;
case 'hourglass':
$arrpoints = array($x1, $y1, $x2, $y1, $x1, $y2, $x2, $y2);
ImageFilledPolygon($this->img, $arrpoints, 4, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 4, $color);
break;
case 'bowtie':
$arrpoints = array($x1, $y1, $x1, $y2, $x2, $y1, $x2, $y2);
ImageFilledPolygon($this->img, $arrpoints, 4, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 4, $color);
break;
case 'target':
ImageFilledRectangle($this->img, $x1, $y1, $x, $y, $color);
Expand All @@ -7096,7 +7116,7 @@ protected function DrawShape($x, $y, $record, $color, $allow_none = TRUE)
break;
case 'home': /* As in: "home plate" (baseball), also looks sort of like a house. */
$arrpoints = array($x1, $y2, $x2, $y2, $x2, $y, $x, $y1, $x1, $y);
ImageFilledPolygon($this->img, $arrpoints, 5, $color);
$this->imageFilledPolygonWrapper($this->img, $arrpoints, 5, $color);
break;
case 'up':
ImagePolygon($this->img, array($x, $y1, $x2, $y2, $x1, $y2), 3, $color);
Expand Down Expand Up @@ -7155,6 +7175,8 @@ protected function DrawDot($row, $column, $x_world, $y_world, $color)
protected function DrawBar($row, $column, $x1, $y1, $x2, $y2, $data_color, $shade_color, $border_color,
$shade_top = TRUE, $shade_side = TRUE)
{
$x1 = floor($x1); $x2 = floor($x2);
$y1 = floor($y1); $y2 = floor($y2);
// Sort the points so x1,y1 is upper left and x2,y2 is lower right. This
// is needed in order to get the shading right, and imagerectangle may require it.
if ($x1 > $x2) {
Expand All @@ -7178,7 +7200,7 @@ protected function DrawBar($row, $column, $x1, $y1, $x2, $y2, $data_color, $shad
} else { // Suppress top shading (Note shade_top==FALSE && shade_side==FALSE is not allowed)
$pts = array($x2, $y2, $x2, $y1, $x2 + $shade, $y1 - $shade, $x2 + $shade, $y2 - $shade);
}
ImageFilledPolygon($this->img, $pts, count($pts) / 2, $shade_color);
$this->imageFilledPolygonWrapper($this->img, $pts, count($pts) / 2, $shade_color);
}

// Draw a border around the bar, if enabled.
Expand Down Expand Up @@ -7853,7 +7875,7 @@ protected function DrawArea($do_stacked = FALSE)
array_push($pts, $xd[$row], $yd[$row][$col]);
}
// Draw it:
ImageFilledPolygon($this->img, $pts, $n_rows * 2, $this->ndx_data_colors[$prev_col]);
$this->imageFilledPolygonWrapper($this->img, $pts, $n_rows * 2, $this->ndx_data_colors[$prev_col]);

$prev_col = $col;
}
Expand Down Expand Up @@ -8148,7 +8170,7 @@ protected function DrawSquaredArea($do_stacked = FALSE)
}

// Draw the resulting polygon, which has (2 * (1 + 2*(n_rows-1))) points:
ImageFilledPolygon($this->img, $pts, 4 * $n_rows - 2, $this->ndx_data_colors[$prev_col]);
$this->imageFilledPolygonWrapper($this->img, $pts, 4 * $n_rows - 2, $this->ndx_data_colors[$prev_col]);
$prev_col = $col;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/stats/package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: search_it/stats
version: '6.9.3'
version: '6.9.4'
author: Friends Of REDAXO

title: 'translate:search_it_stats_plugin_title'
Expand Down

0 comments on commit fe7cd68

Please sign in to comment.