PluginProbe
404 Solution / 4.3.3
404 Solution v4.3.3
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / php / wordpress / WPDBExtension.php

WPDBExtension.php in 404 Solution 4.3.3, at includes/php/wordpress/WPDBExtension.php

55 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 if (!defined('ABSPATH')) {
5 exit;
6 }
7
8 if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
9 class ABJ_404_Solution_WPDBExtension_PHP7 extends wpdb {
10 /**
11 * @param string $query
12 * @return string|null
13 */
14 public function public_strip_invalid_text_from_query(string $query) {
15 try {
16 $result = $this->strip_invalid_text_from_query($query);
17 return is_string($result) ? $result : null;
18 } catch (Exception $e) { // allow-silent-catch: strip_invalid_text_from_query wrapper; null signals "no usable result" and caller falls back to original query. The exception is NOT dropped: abj404_logRuntimeWarning() records it below before we return.
19 if (function_exists('abj404_logRuntimeWarning')) {
20 abj404_logRuntimeWarning('WPDBExtension_PHP7::public_strip_invalid_text_from_query failed', $e);
21 }
22 return null;
23 } catch (Error $e) { // allow-silent-catch: PHP 7+ Error from protected method access; same null fallback as Exception path. The error is NOT dropped: abj404_logRuntimeWarning() records it below before we return.
24 if (function_exists('abj404_logRuntimeWarning')) {
25 abj404_logRuntimeWarning('WPDBExtension_PHP7::public_strip_invalid_text_from_query failed', $e);
26 }
27 return null;
28 }
29 }
30 }
31 } else {
32 class ABJ_404_Solution_WPDBExtension_PHP5 extends wpdb {
33 /**
34 * @param string $query
35 * @return string|null
36 */
37 public function public_strip_invalid_text_from_query(string $query) {
38 try {
39 $result = $this->strip_invalid_text_from_query($query);
40 /** @var mixed $resultMixed */
41 $resultMixed = $result;
42 if (is_object($resultMixed) && method_exists($resultMixed, 'get_error_message')) {
43 return 'WP_Error: ' . $resultMixed->get_error_message();
44 }
45 return is_string($result) ? $result : null;
46 } catch (Exception $e) { // allow-silent-catch: strip_invalid_text_from_query wrapper; null signals "no usable result" and caller falls back to original query. The exception is NOT dropped: abj404_logRuntimeWarning() records it below before we return.
47 if (function_exists('abj404_logRuntimeWarning')) {
48 abj404_logRuntimeWarning('WPDBExtension_PHP5::public_strip_invalid_text_from_query failed', $e);
49 }
50 return null;
51 }
52 }
53 }
54 }
55