The MU forums have moved to WordPress.org

Global Problem with Recent Post Widgets (4 posts)

  1. zappoman
    Member
    Posted 16 years ago #

    Hey All,

    I've just discovered and fixed a small problem in the "Recent Posts" widget.

    Basically this widget creates a second "loop" and will side effect several of the post globals (like $id and $post). The result will effect any downstream plugin that thinks it can count on these globals being available. This can also manifest in any theme (like Tarski) that has post related template calls AFTER the side bar widget.

    I've fixed this problem but saving $post in a local variable and then resetting it after the loop call. I also call setup_postdata() to restore the other globals.

    I just checked the latest version of widgets.php from "http://svn.wp-plugins.org/widgets/trunk/" and it still has this issue in it.

    Any suggestions on how to add this to a bug list somewhere.

    Sorry for being out of the loop on this process.

    I'll put the diff up on my development blog.

  2. Farms
    Member
    Posted 16 years ago #

    Nice find, thanks for sharing :)

  3. zappoman
    Member
    Posted 16 years ago #

    I'm actually really surprised this hasn't been seen by someone else already. This bug was haunting us for the last couple days, and caused all kinds of trouble.

    Thank goodness we're only in beta and have a small number of users.

    The effect of this bug, if you're using a theme like Tarski that shows the sidebar BEFORE the comments control, is that any comments posted will get wired up to the WRONG post.

    James, do you have the Tarski theme on edublogs? Have you never seen this issue before?

  4. zappoman
    Member
    Posted 16 years ago #

    Oh yeah, I'm also going back and double checking all of my widgets to make sure that if they side-effect the post globals that they do this save and restore trick.

About this Topic

  • Started 16 years ago by zappoman
  • Latest reply from zappoman