WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] Bug in sql function in YARPP_Cache (11 posts)

  1. Daniel Dvorkin (MZAWeb)
    Member
    Posted 1 year ago #

    Around line 171 of class-cache.php you're doing:

    foreach ( (array)$weight['tax'] as $tax => $weight )

    Setting the inner value of that foreach to $weight destroys the original $weight, so a few lines below when you do:

    if ( count($exclude_tt_ids) || count((array) $weight['tax']) || count($require_tax) )

    $weight['tax'] is invalid, throws a notice, and it's always 0.

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    Oh my god. Thank you for bringing this to my attention... this is terribly embarrassing, and I guess we've all been very lucky that YARPP has continued to function in the mean time.

    My understanding of the effect is that count((array) $weight['tax']) was interpreted as count(array(0)), and thus the term_relationships were being joined even when not necessary. Is that right? How did you find this?

    Will fix in a quick bugfix release.

  3. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    4.0.1 beta 2:

    http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.4.0.1b2.zip

    Please let me know what you think. Thanks again!

  4. Daniel Dvorkin (MZAWeb)
    Member
    Posted 1 year ago #

    No, the other way around. It wasn't adding the joins, so the query was failing. In fact, it wasn't working at all for me when using the YARPP_Cache_Bypass (using yarpp_get_related manually). It was working on table cache, though, when using the auto add.

    Didn't test it, but http://plugins.svn.wordpress.org/yet-another-related-posts-plugin/tags/4.0.1b2/class-cache.php looks good.

  5. Daniel Dvorkin (MZAWeb)
    Member
    Posted 1 year ago #

    So, you're right about count(array(0)), but that's 0, so it was not entering the IF.

  6. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    count(array(0)) is 1 :) so it was entering.

  7. Daniel Dvorkin (MZAWeb)
    Member
    Posted 1 year ago #

    php -r 'var_dump(count($arr["bad_index"]));'
    title:7: bad math expression: operand expected at
    "bad_index...'
    1;phpPHP Notice: Undefined variable: arr in Command line code on line 1
    PHP Stack trace:
    PHP 1. {main}() Command line code:0

    Notice: Undefined variable: arr in Command line code on line 1

    Call Stack:
    0.0001 626184 1. {main}() Command line code:0

    int(0)
    `

    it was not :)

  8. Daniel Dvorkin (MZAWeb)
    Member
    Posted 1 year ago #

    Hate the formatting for code. Let's try again:

    php -r 'var_dump(count($arr["bad_index"]));'
    title:7: bad math expression: operand expected at `"bad_index...'
    1;phpPHP Notice: Undefined variable: arr in Command line code on line 1
    PHP Stack trace:
    PHP 1. {main}() Command line code:0

    Notice: Undefined variable: arr in Command line code on line 1

    Call Stack:
    0.0001 626184 1. {main}() Command line code:0

    int(0)

  9. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    well, $arr was defined, so I think it's 1... but either way, can you confirm that this is fixed for 4.0.1?

  10. Daniel Dvorkin (MZAWeb)
    Member
    Posted 1 year ago #

    Yup, working.

    It's weird, because I found the issue thanks to an error on my mysql log because of the missing join. Anyway, it's fixed.

    Thanks!

  11. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    Great! Hoping to push this release tomorrow... want to let it bake a bit. If you want, the latest beta is b3:

    http://downloads.wordpress.org/plugin/yet-another-related-posts-plugin.4.0.1b3.zip

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.