Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice on Addons page with v7.2 #896

Open
Olwyne opened this issue Feb 23, 2023 · 0 comments
Open

Notice on Addons page with v7.2 #896

Olwyne opened this issue Feb 23, 2023 · 0 comments

Comments

@Olwyne
Copy link

Olwyne commented Feb 23, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant