WordPress.org

Ready to get started?Download WordPress

Forums

Category Icons
[resolved] WordPress 3.5 Admin Error (18 posts)

  1. Jeff
    Member
    Posted 1 year ago #

    The following is being thrown in the Admin area after upgrading to WordPress 3.5. Running latest version of category icon plugin. Not seeing an issue on the front end as yet.

    Warning: Missing argument 2 for wpdb::prepare(), called in /home/webphysi/public_html/wpb/wp-content/plugins/category-icons/category_icons.php on line 1047 and defined in /home/webphysi/public_html/wpb/wp-includes/wp-db.php on line 990

    http://wordpress.org/extend/plugins/category-icons/

  2. maxwelton
    Member
    Posted 1 year ago #

    I see the same error, just so you know it's not a one-off thing.

  3. maxwelton
    Member
    Posted 1 year ago #

    It looks like a few "prepare" calls throughout the plugin need to be modified, not just that one instance.

    If you want to edit the plugin yourself to work as it was before until an update comes out, the following seems to work--no guarantees. I have not added or deleted any icons since making this mod, I just wanted my admin area and public-facing pages to not show the error(s).

    Line 1047, add ",0" right before the final two parens:

    $wpdb->query($wpdb->prepare("CREATE TABLE IF NOT EXISTS$wpdb->ig_caticons(cat_idINT NOT NULL ,priorityINT NOT NULL ,iconTEXT NOT NULL ,small_iconTEXT NOT NULL , PRIMARY KEY (cat_id))",0));

    Line 1338, add ",0" similarly:

    $datas = $wpdb->get_results($wpdb->prepare("SELECT cat_id, priority, icon, small_icon FROM $wpdb->ig_caticons",0));

  4. Jeff
    Member
    Posted 1 year ago #

    @maxwelton - Appreciate the above as I hadn't spent a lot of time looking at it yet. Now that I do the prepare probably isn't necessary as there aren't any parms in the SQL. Looks like the other uses of prepare aren't always setting it up as you would expect either.

    I did make the two noted changes and the warning is gone. It also cleared up a warning on another plugin that was around headers being sent. Probably a result of the first warning being sent.

    Thanks!

  5. DougJoseph
    Member
    Posted 1 year ago #

    @maxwelton

    Thanks! I had the same issue, and the fix you listed worked.

  6. 6clicks
    Member
    Posted 1 year ago #

    @maxwelton thank's a lot .... seems to work ...

  7. Winock123
    Member
    Posted 1 year ago #

    @maxwelton

    Here the same, ThankĀ“s a lot !

  8. jorgeorpinel
    Member
    Posted 1 year ago #

    Glad to see a solution has been posted. @maxwelton's tip is incomlpete however. There's several lines that need to be changed in the file.

    For a complete fix please update category_icons_php with this file I bug-fixed: https://docs.google.com/open?id=0B7JEImS_HANHVlRzNnJrb3E2QVU

  9. Jeff
    Member
    Posted 1 year ago #

    FYI - Posting the official commentary on this and how to address it. This is mainly meant for the plugin author, @Submarine, but may be interesting to others. And known to some that already have responded.

    http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

  10. allstone
    Member
    Posted 1 year ago #

    The google doc that jorgeopinel posted isn't allowing a select-all, copy and paste.

  11. allstone
    Member
    Posted 1 year ago #

    I made the two changes that @ maxwelton listed, and the errors are no longer appearing at the top of the page on the frontend or messing up the admin-backend. However in the category view, I get the following error above the graphic that is now correctly displaying:

    Warning: Missing argument 2 for wpdb::prepare(), called in /usr/www/users/taurus/gancao/wp-content/plugins/category-icons/category_icons.php on line 1360 and defined in /usr/www/users/taurus/gancao/wp-includes/wp-db.php on line 990

  12. allstone
    Member
    Posted 1 year ago #

    Ha! I just added the ,0 to the end of line 1360 (like the two other edits above) and the whole thing works perfectly now.

  13. baco99
    Member
    Posted 1 year ago #

    Hello allstone, I have the same problem, please can you tell me where is the 1360 line? I can't find where to add ,0

  14. allstone
    Member
    Posted 1 year ago #

    Hi Baco99, you'll want to modify the file called "category_icons.php". Most text editing programs provide the ability to display and even jump to a given line number, however lacking that, search for this:
    if ($row = $wpdb->get_row($wpdb->prepare("SELECT cat_id, priority, icon, small_icon FROM $wpdb->ig_caticons WHERE cat_id IN($instr) ORDER BY priority DESC LIMIT 1")))

    Change it to this:
    if ($row = $wpdb->get_row($wpdb->prepare("SELECT cat_id, priority, icon, small_icon FROM $wpdb->ig_caticons WHERE cat_id IN($instr) ORDER BY priority DESC LIMIT 1",0)))

  15. danbp
    Member
    Posted 1 year ago #

    Hi guys,

    sorry to say that, but you're wrong !
    Because 0 means... zero, you can't give "nothing" as second argument.

    For sure, the warning disapear, because "something" is placed as second, but this "something" is empty. So the query is already wrong.

    read attentively the doc http://make.wordpress.org/core/2012/12/12/php-warning-missing-argument-2-for-wpdb-prepare/

    None of the examples are telling about 0, but $arg.

    So, IMO, this example
    if ($row = $wpdb->get_row($wpdb->prepare("SELECT cat_id, priority, icon, small_icon FROM $wpdb->ig_caticons WHERE cat_id IN($instr) ORDER BY priority DESC LIMIT 1")))

    should be

    if ($row = $wpdb->get_row($wpdb->prepare("SELECT cat_id, priority, icon, small_icon FROM $wpdb->ig_caticons WHERE cat_id IN($instr) ORDER BY priority DESC LIMIT 1", $cat_id, $priority, $icon, $small_icon)))

  16. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    I've published the 2.2.6 version, if someone want to test it, please.

  17. submarine
    Member
    Plugin Author

    Posted 1 year ago #

    The issue seems to be resolved with WP 3.5.1.

  18. Sith Lord Goz
    Member
    Posted 7 months ago #

    Hi -

    I see you linked to version 2.2.6, but the latest on the WP repo is still 2.2.3
    http://wordpress.org/plugins/category-icons/changelog/

    Is it safe to update to 2.2.6 or is it still untested?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.