elementor / elementor/wp2static

Notice on Addons page with v7.2

Open
#896 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.5k
Forks
294
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

On WP2Static 7.2, the following notice appears above the Addons page :

```
Notice: Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. Please see [Debugging in WordPress](https://wordpress.org/support/article/debugging-in-wordpress/) for more information. (This message was added in version 3.9.0.) in /var/www/html/wp-includes/functions.php on line 5835
```

This is due to Addons.php (line 53) file building a query string without a `%s` placeholder in the case where `$type === 'all'`

```
public static function getAll( string $type = 'all' ) : array {
global $wpdb;

$table_name = $wpdb->prefix . 'wp2static_addons';

$query_string = "SELECT * FROM $table_name";
$query_params = [];
if ( $type !== 'all' ) {
$query_string .= ' WHERE type = %s';
$query_params[] = $type;
}
$query_string .= ' ORDER BY type DESC';

return $wpdb->get_results(
$wpdb->prepare( $query_string, $query_params )
);
}
```

**To Reproduce**
Steps to reproduce the behavior:
1. Go to Addons page (with debug mode on)
2. See notice

**Expected behavior**
No notice should appear on the Addons page

**Screenshots**

Capture d’écran 2023-02-23 à 16 47 19

**Environment (please complete the following information):**
- Hosting OS: MacOS 12.6.3,
- Web server setup : Docker
- Hosting company : local computer

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.