Skip to content

Commit

Permalink
SL-7164: php8.3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sape-petrov committed Aug 7, 2024
1 parent 35bb870 commit f9c5ba7
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 10 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## RU

Плагин Wordpress для sape.ru **[v3.4.2](https://github.com/sape-ru/client-code-wordpress/blob/v3.4.2/plugin/saperu-integration-v3.4.2.zip?raw=true)**
Плагин Wordpress для sape.ru **[v3.4.3](https://github.com/sape-ru/client-code-wordpress/blob/v3.4.3/plugin/saperu-integration-v3.4.3.zip?raw=true)**

- встроенная версия клиентского кода Sape: 1.5.3
- встроенная версия клиентского кода Sape: 1.5.4

### Системные требования
WordPress 4.2+ [системные требования для разных версий](https://wordpress.org/about/requirements/)
Expand All @@ -18,12 +18,13 @@ WordPress 4.2+ [системные требования для разных в
- статьи
- Совместимо с Word Press 6.0
- Добавлена возможность показа проверочного кода
- Совместимо с php8.3

## EN

Wordpress plugin for sape.ru webmaster services integration **[v3.4.2](https://github.com/sape-ru/client-code-wordpress/blob/v3.4.2/plugin/saperu-integration-v3.4.2.zip?raw=true)**
Wordpress plugin for sape.ru webmaster services integration **[v3.4.3](https://github.com/sape-ru/client-code-wordpress/blob/v3.4.3/plugin/saperu-integration-v3.4.3.zip?raw=true)**

- built in version of sape.ru's client code: 1.5.3
- built in version of sape.ru's client code: 1.5.4

### System requirements
WordPress 4.2+ [requirements for different versions](https://wordpress.org/about/requirements/)
Expand All @@ -36,4 +37,5 @@ WordPress 4.2+ [requirements for different versions](https://wordpress.org/abou
- advertisement blocks of rtb.sape
- articles
- Compatible with Word Press 6.0
- The ability to display verification code was added
- The ability to display verification code was added
- php8.3 compatibility
Binary file removed plugin/saperu-integration-v3.4.2.zip
Binary file not shown.
Binary file added plugin/saperu-integration-v3.4.3.zip
Binary file not shown.
10 changes: 8 additions & 2 deletions src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Tags: sape, seo, link, site, teaser, rtb
Requires at least: 4.2
Tested up to: 6.0.1
Stable tag: trunk
Version: 3.4.2
Version: 3.4.3
Author: Sape.ru
Author URI: https://www.sape.ru/
License: GPLv2 or later
Expand Down Expand Up @@ -100,6 +100,9 @@ Interface edits
### v 3.4.2
Translate edits

### v 3.4.3
- php8.3 compatibility

## Changelog
### v 0.01
First version
Expand Down Expand Up @@ -159,4 +162,7 @@ The ability to display verification code was added
Interface edits

### v 3.4.2
Translate edits
Translate edits

### v 3.4.3
- php8.3 compatibility
70 changes: 68 additions & 2 deletions src/sape/sape.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class SAPE_base
{
protected $_version = '1.5.3 (WP v3.4.2)';
protected $_version = '1.5.4 (WP v3.4.3)';

protected $_verbose = false;

Expand Down Expand Up @@ -78,6 +78,12 @@ class SAPE_base
protected $_debug = false;
protected $_file_contents_for_debug = array();

/**
* Глубина стека, передаваемая в debug
* @var int
*/
protected $_debug_stack_max_deep = 5;

/**
* Регистронезависимый режим работы, использовать только на свой страх и риск
* @var bool
Expand Down Expand Up @@ -118,6 +124,31 @@ class SAPE_base

protected $_user_agent = '';

/**
* обязательный вывод
* @var string|null
*/
protected $_page_obligatory_output = null;

/**
* Опции запуска скрипта
* @var array|mixed|null
*/
protected $_options = array();

/**
* Запрошенный uri
* @var mixed|null
*/
protected $_server_request_uri = null;
protected $_getenv_request_uri = null;

/**
* Хеш пользователя
* @var string|null
*/
protected $_SAPE_USER = null;

public function __construct($options = null)
{

Expand Down Expand Up @@ -257,7 +288,10 @@ protected function _get_full_user_agent_string()
*/
protected function _debug_output($data)
{
$data = '<!-- <sape_debug_info>' . @base64_encode(serialize($data)) . '</sape_debug_info> -->';
$data = '<!-- <sape_debug_info>' .
@base64_encode(serialize($this->prepare_debug_data($data, $this->_debug_stack_max_deep))) .
'</sape_debug_info> -->'
;

return $data;
}
Expand Down Expand Up @@ -638,6 +672,38 @@ protected function _return_obligatory_page_content()
return $html;
}

/**
* Подготовить данные для отладки
* @param mixed $data
* @param int $max_deep максимальная глубина обхода массивов и вложенных объектов
* @return mixed
*/
protected function prepare_debug_data(
$data,
$max_deep
) {
if ($max_deep < 1 || $data instanceof \Closure) {
return null;
} elseif (is_array($data)) {
$result = array();
foreach ($data as $key => $value) {
$result[$key] = $this->prepare_debug_data($value, $max_deep - 1);
}

return $result;
} elseif (is_object($data)) {
$result = array();
$filledObjectFields = get_object_vars($data);
foreach ($filledObjectFields as $key => $value) {
$result[$key] = $this->prepare_debug_data($value, $max_deep - 1);
}

return $result;
}

return $data;
}

/**
* Вернуть js-код
* - работает только когда параметр конструктора show_counter_separately = true
Expand Down
2 changes: 1 addition & 1 deletion src/saperu-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Sape.ru integration
Plugin URI: https://github.com/sape-ru/client-code-wordpress/releases
Description: Plugin for Sape.ru webmaster services integration
Version: 3.4.2
Version: 3.4.3
Author: Sape.ru
Author URI: http://www.sape.ru/
License: GPLv2 or later
Expand Down

0 comments on commit f9c5ba7

Please sign in to comment.