WordPress.org

Ready to get started?Download WordPress

Forums

sql-error in sidebar links after upgrade to 2.2.2 (33 posts)

  1. hpz
    Member
    Posted 7 years ago #

    After upgrading from wp2.1.3 to 2.2.2 the links/blogrolls didn't show up, instead I got the following sql-error:

    WordPress database error: [Unknown column 'name' in 'order clause']
    SELECT * FROM wp_categories WHERE cat_ID > 0 AND link_count > 0 ORDER BY name ASC

    After tracking down the problem I found the modified function call extract($r, EXTR_SKIP); in category.php:get_categories to be the reason.

    In wp 2.1.3 the EXTR_SKIP Parameter is not used.
    So I'm not sure if this is really a bug or if there is another reason, why the variable $orderby already exists with a (wrong) value of 'name'?

    (I am runnung wp with PHP-4.3.2)
    Somebody else has seen this?
    Thanks!

  2. phaedral
    Member
    Posted 6 years ago #

    I've got a virgin install of WP, 2.2.2, same problem. I don't quite understand from your post what you changed after finding the EXTR_SKIP in category.php. Could you be enticed to give a little more detail on the fix, pretty please?

  3. Chris_K
    Member
    Posted 6 years ago #

    Instead of modifying core code, you'd be happier either getting a theme that uses wp_list_bookmarks or converting your current theme to use the same.

  4. phaedral
    Member
    Posted 6 years ago #

    Handy, thanks! I'm actually trying to create a theme, and am following advice to start with default 1.6. It does seem odd that both themes which ship with the app have this problem on a virgin install.

    The new data I can add is that in default 1.6 the error clears when I navigate to a category; same for the 2-column-right-fluid "blank" theme from http://www.tomorrows-laundry.com. And I can manually change the query part of the address in the address bar, making it read, for example, ?cat=99, even though I only have two categories so far. In classic 1.5 none of this makes any difference, the error message is always present in the sidebar.

    Meanwhile I guess I'll see what I can do with wp_list_bookmarks in default 1.6 and the blank.

  5. moshu
    Member
    Posted 6 years ago #

    If you don't have the wp_list_bookmarks in the sidebar.php of the default theme... then that's NOT a "virgin 2.2.2 install" as you stated!

  6. brookeluder
    Member
    Posted 6 years ago #

    hi I downloaded 2.2.3 for a virgin install yesterday and I have this problem also. I'm not really a coder. hpz did you mean we should change $orderby to $bookmarks ?? This may be a dumb question but I'd love to fix the problem. cheers

  7. phaedral
    Member
    Posted 6 years ago #

    Moshu, No need to shout or exclaim. It is not an upgrade. It was virgin on Friday when I installed it; I'd never monkeyed with WP before, been using blosxom. Since then I have deferred worrying about this sidebar db problem while I tried to figure out the spaghetti that was style.css in the default theme. The shipped themes are untouched; I work with copies. Line 57 of sidebar.php reads, omitting indentation:

    <?php wp_list_bookmarks(); ?>

    I said in my last note I'd look at HandySolo's suggestions because that seemed more polite that saying I recalled seeing wp_list_bookmarks without first doing a little double checking.

    Since you're a moderator, I'll put the question to you directly, is it news to you that the shipped themes in 2.2.2 barf in the sidebar as described?

  8. brookeluder
    Member
    Posted 6 years ago #

    hi I fixed mine! one of the other posts mentioned nmaes for funtions being changed! I'm using the 2.2.3 basic template (kubrick). in this template go to the 'sidebar.php' and down the bottom where it says <?php wp_list_bookmarks(); ?> replace line with <?php get_linksbyname(); ?>
    hope that helps someone! :)

  9. phaedral
    Member
    Posted 6 years ago #

    Addendum: The "blank" theme does not have wp_list_bookmarks anywhere in sidebar.php; default does. Both barf in the sidebar when there is no ?cat=N in the address bar; both are just fine if there is.

    On the other hand, both default and classic do have wp_list_bookmarks in their respective sidebar.php, but their behavior is different; nothing seems to keep classic from barfing in the sidebar.

    This would seem to be strong evidence that wp_list_bookmarks isn't entirely relevant to the problem. Perhaps someone could explain hpz's hack for us to use in the meantime?

  10. phaedral
    Member
    Posted 6 years ago #

    brookluder, Excellent; thanks! Mind telling us which thread in case there are other juicy tidbits?

  11. brookeluder
    Member
    Posted 6 years ago #

    sure!
    the thread was:
    http://wordpress.org/support/topic/131681?replies=4

    and the page with the updated tags is here:
    http://codex.wordpress.org/Template_Tags

  12. phaedral
    Member
    Posted 6 years ago #

    brookeleuder, Do I understand correctly that our "fix" is to replace the new-for-2.1-forward wp_list_bookmarks with the deprecated get_linksbyname? I just plain would never have thought to try the deprecated tag, but props to you for figuring it out. ;)

    Also, perhaps for the wider audience, why does this yield a batch of linked names in my sidebar, for Donncha, Michel, Ryan, Matt, Mike, Alex, Dougal, each linked to an offsite page? Am I going to have to fish them out of the db? Or is there a better fix.

    Think I'm gonna have to just experiment with hpz's tweak.

  13. brookeluder
    Member
    Posted 6 years ago #

    ah no easy fix! the names are like the example "about" page! just go into the admin section and delete them from the Blogroll page!

  14. phaedral
    Member
    Posted 6 years ago #

    brookeluder, you totally rock. I'm plenty fine removing the demo blogroll data; just hadn't realized that's what I was seeing.

  15. phaedral
    Member
    Posted 6 years ago #

    For the blank theme I'm working with I had to replace get_link_list with the deprecated get_linksbyname; this fixed the frontpage problem (it was always fine if the query string identified category display.)

    Thanks again, brookeluder, for the clue.

  16. Bodhipaksa
    Member
    Posted 6 years ago #

    And now you need urgently to upgrade to 2.2.3 because there are publicly available exploits for hacking 2.2.2. Fortunately it's a painless upgrade.

  17. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Err... what? You should be using wp_list_bookmarks(), not deprecated functions. wp_list_bookmarks works fine in 2.2.2 and 2.2.3, I use it myself.

  18. hpz
    Member
    Posted 6 years ago #

    I'm finally glad, that others have the same problem.
    I verified again and I can confirm, that the problem is *not* related to the theme (wp_list_bookmarks), or at least not directly(?). The problem occurs also with the default wordpress theme.

    By debugging I came to the line 32 in file wp-includes/category.php, which I changed again:

    //extract($r, EXTR_SKIP);
     extract($r);

    Maybe, the key to this problem lies in the reason for this modif? I don't know..
    Or might it even be related to some PHP version?

    If somebody else could verify if this fix works also for others?

  19. phaedral
    Member
    Posted 6 years ago #

    @Haecceity, that's just plain dumb bad luck on my part, that I'd start this project days before an upgrade.

    @hpz, you've got the fix that wins; many many thanks for the time and energy you must have put in to track this down. I hope the dev team is accordingly appreciative.

    Off to upgrade now. :(

  20. phaedral
    Member
    Posted 6 years ago #

    @hpz, meant to add the fix worked for both shipped themes in 2.2.2 and the 2-column-fluid-right blank theme from tomorrows-laundry. Those are the only ones I'm tinkering with, but they each handle that front page a little differently, showing your fix to be pretty robust. Peace.

  21. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Having $orderby = 'name' is perfectly acceptable. The get_categories function adds "cat_" to the beginning of that.

    Verify that your version of wp_includes\category.php is the latest version.

    And I still can't reproduce this with a default 2.2.2 installation, or 2.2.3 for that matter.

  22. Bodhipaksa
    Member
    Posted 6 years ago #

    Phaedral: I feel like I'm always upgrading! I have something like ten sites now and my heart sinks every time I see there's an upgrade. I've just finished updating all my sites and in a week or so I'll probably have to do it all again.

  23. phaedral
    Member
    Posted 6 years ago #

    @Haecceity, a pal of mine is trying to sell me on subversion for updates. Sounds like you could benefit therefrom, if you're not already doing that way.

    Instead of upgrading I clobbered the whole mess and installed 2.2.3 from scratch; brand new tables in a brand new db and brand new files in a brand new directory. Same problems, which hpz's fix fixed.

    @Otto42, just for fun, are you trying your url direct in your address bar, like http://www.otto42.com/wordpress/ , or are you following a link? When I follow a link, say from the "view site" link in the presentation page of the admin, that sends me to an address with a ?cat=N, where N is some integer matching an extant category. In that situation I was not getting the complained of garbage. But when going in "the front door" with nothing but the raw url in the address bar I got the complained of garbage. Either way, just because you can't repro doesn't mean me or others aren't having the problem, does it?

  24. Bodhipaksa
    Member
    Posted 6 years ago #

    Phaedral: Thanks for the tip on subversion. I'm looking into it and it does seem like it would be a good option for me.

  25. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    @Otto42, just for fun, are you trying your url direct in your address bar, like http://www.otto42.com/wordpress/ , or are you following a link? When I follow a link, say from the "view site" link in the presentation page of the admin, that sends me to an address with a ?cat=N, where N is some integer matching an extant category. In that situation I was not getting the complained of garbage. But when going in "the front door" with nothing but the raw url in the address bar I got the complained of garbage.

    Okay, see, that's useful information. Why didn't you post that before? That says that something is weird with your query, although why it would affect the bookmarks I still don't understand.

    You say that you didn't get this garbage, but what did you get in it's place? The list of bookmarks? Or what?

    This problem just seems very poorly defined from reading this thread. You're getting this error, okay, I get that. But under what circumstances? I mean, I can give you code that will produce that error every time, but unless you can get it with a completely default installation, it's probably not a WordPress bug.

    Either way, just because you can't repro doesn't mean me or others aren't having the problem, does it?

    That which cannot be reproduced cannot be fixed. Furthermore, hpz's "fix" of eliminating the EXTR_SKIP shouldn't actually work. All removing that does is open potential security holes.

    If a bug actually exists, then it exists for everybody. This is software, not magic. What you get, everybody should be getting. The fact that we're not suggests that there's something special about your setup. I'm trying to determine what that special thing is so that I can work out the problem and produce a fix. Just because some code change works for you does not make it the correct code change to make for everybody.

    Just having a "fix" doesn't cut it. The dev team is going to want to know what the problem actually is, and why this fix is the correct way to solve it.

  26. hpz
    Member
    Posted 6 years ago #

    This problem just seems very poorly defined from reading this thread. You're getting this error, okay, I get that. But under what circumstances? I mean, I can give you code that will produce that error every time, but unless you can get it with a completely default installation, it's probably not a WordPress bug

    I never claimed it to be a wordpress bug. This was a question, only.

    That which cannot be reproduced cannot be fixed. Furthermore, hpz's "fix" of eliminating the EXTR_SKIP shouldn't actually work. All removing that does is open potential security holes.

    The problem is the reproduction. This error seems only to come up under some special conditions. And that is the point, to find out, what these special conditions are.

    I reanalysed these conditions and I came to the conclusion, that this error has to be related to my PHP-Version.
    So, I'm running PHP-4.3.2 on RedHat 3 (php-4.3.2-39).
    Let me quickly explain, why:
    At the line 31 in file gategory.php (function get_categories), the statement extract($r, EXTR_SKIP); should create an entry $orderby in the PHP-Symboltable, with the parameter to skip if there is already such an entry. And this is the problem, that there exists already a symbol $orderby with the value 'name', so the extract()-function doesn't override this one!!! I checked that by inserting the follwing statement just before line 31:
    if (isset($orderby)) echo "</br>orderby before = $orderby</br>"; and guess what appeared on my page?
    orderby before = name

    But in the code there is absolutely no symbol '$orderby' referenced before the line 31. So, where the hell comes this symbol?

    To give another proof is to insert the following statement before line 31:

    unset($orderby);
    extract($r, EXTR_SKIP);

    This fixes also the error! So to be more precise, this should probably be regarded as a hack for working with certain php-versions, rather than a wordpress fix.

    It remains to check what PHP-Version others, having the same problem, are running.

  27. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Wow, okay, now that makes more sense, although I don't understand why $orderby would be set at that point. parse_str *could* set it, except that with the second parameter ($r in this case), it's not supposed to set local vars like that.

    Have you tried with a different version of PHP? Might be worth upgrading to PHP5.

  28. hpz
    Member
    Posted 6 years ago #

    This is really weired! When entering the function isset($orderby) returns false. But a few lines further isset($orderby) returns true !?

    I haven't had time yet to move to another PHP version, but I plan to do it as soon as possible.

    So, what php version are the others running?
    Thanks for your feedback.

  29. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Try using this code instead, see if it makes a difference:

    function wp_list_bookmarks($args = '') {
    	$defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
    		'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1,
    		'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '<h2>', 'title_after' => '</h2>',
    		'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat',
    		'category_before' => '<li id="%id" class="%class">', 'category_after' => '</li>');
    	$r = wp_parse_args($args,$defaults);
    	extract($r, EXTR_SKIP);
    
    	$output = '';
    ...

    That uses the wp functions to parse the args instead, which may eliminate the problem.

  30. phaedral
    Member
    Posted 6 years ago #

    php 4.3.2 Linux 2.4.21-47.ELsmp #1 SMP Wed Jul 5 20:38:41 EDT 2006 i686

    hth

Topic Closed

This topic has been closed to new replies.

About this Topic