Open mack-linebaugh opened 5 years ago
It looks like the main issue is with the usage of $wpdb->prepare
, since it expects 2 arguments and only one is provided.
https://developer.wordpress.org/reference/classes/wpdb/prepare/
It's preforming a sprintf()
find-and-replace on the query, and it's expecting something like this:
$blogids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM %s", $wpdb->blogs ) );
I'm pasting this solution I generously received from @jwcounts on Slack, which solved the issue for me:
The $wpdb->prepare()
function in Wordpress, which is referenced in the nprstory_activation()
function, needs 2 arguments to work correctly: a query with placeholders, and the data to replace those placeholders.
Example:
$wpdb->prepare( 'SELECT blog_id from %s', $wpdb->blog );
The %s
is a placeholder for a string, and the $wpdb->blog
is the string that will replace it. The prepare()
function performs this replacement in order to help organize and sanitize the query
So, line 74 in the ds-npr-api.php
should look like this:
$blogids = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM %s", $wpdb->blogs ) );
I had this plugin up and working on a single install of Wordpress 5.1 and PHP 7.2. I decided to switch it a multisite install. Afterward, I couldn't activate the plugin. I deleted it, reinstalled it, and kept getting the same error:
So the error originates in this function (line 74, referenced in the error message, is in bold):
From Wordpress documentation:
Anyone know of a fix for this? One that doesn't involve editing wp-db.php, class-wp-hook.php, and plugin.php?