CodingHelp with MySQL (i think) problem?

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  Jo (JELLS)   
 To:  Peter (BOUGHTONP)     
31182.6 In reply to 31182.4 
hehe... Well, no one's replied to my post over there yet.
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)      
31182.7 In reply to 31182.5 

I realised that once I'd posted, and I'm on lite mode just now, so couldn't be bothered faffing around to edit.

 

I'll have a look at my own Wordpress site tonight to see what the code's like.


Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)   
 To:  Kenny J (WINGNUTKJ)     
31182.8 In reply to 31182.7 
Ta - i'd appreciate that.
0/0
 Reply   Quote More 

 From:  Matt  
 To:  Jo (JELLS)      
31182.9 In reply to 31182.1 

The syntax for LIMIT on the end of the query is incorrect. It should contain a second number after the comma, i.e. LIMIT 0, 10.

 

One of the WordPress PHP scripts is probably supposed to check for a variable in the URL query which tells the script how many entries form your blog it is supposed to output into the RSS feed. If this script isn't checking the variable correctly and an empty string (or worse any data) is being allowed to be used to form part of the LIMIT clause then that could cause the error you've described.

 

To fix it you could try and upgrade WordPress to see if it is a known bug that has been squashed in a newer version. Failing that it's probably best to tell them about it ASAP in case the bug can be used to perform an SQL injection attack.

doohicky

0/0
 Reply   Quote More 

 From:  Jo (JELLS)   
 To:  Matt     
31182.10 In reply to 31182.9 

Thanks. I'll give updating a try...

 

But why then does the feed work for everyone else except this one aggregator? I have a feed for the blog set up with LiveJournal, and it still works (as in new posts show up), two other blog aggregators still show my new posts as i make them, and if someone subscribes to my blog's feed, it works there too (at least, it does for me - and yes, i subscribe to my own blog's feed).

 

And as i said, this was working fine up until i moved the blog database to the new hosting a few weeks ago. So i'm not certain it's a WP issue and maybe something that went screwy with the database import? Altho wouldn't that bugger it up for all feeds from my blog?

0/0
 Reply   Quote More 

 From:  Matt  
 To:  Jo (JELLS)      
31182.11 In reply to 31182.10 

I don't know.

 

If I had to guess, I would say the feed aggregator that has the problem could quite possibly be trying to limit the number of entries it is sent and because of this [possible] bug in WordPress the RSS feed isn't correctly generated and it falls over.

 

Meanwhile the aggregators that do work are not limiting the number of entries they fetch which means the bug doesn't come into play for them.

 

Or it could be the other way around and WordPress is expecting a URL Query variable to tell it how many entries to fetch and the troublesome aggregator isn't providing it.

doohicky

0/0
 Reply   Quote More 

 From:  Jo (JELLS)   
 To:  Matt     
31182.12 In reply to 31182.11 

Well, i'll start by upgrading to 2.0.5 and see what that solves, if anything.

 

Thanks again!

0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)      
31182.13 In reply to 31182.1 
The offending function is get_posts() in the wp-includes folder. Like Matt, says, the LIMIT bit at the end should have a valid value. In my version, the code is:

PHP code:
 
function get_posts($args) {
	global $wpdb;
	parse_str($args, $r);
	if ( !isset($r['numberposts']) )
		$r['numberposts'] = 5;
	if ( !isset($r['offset']) )
		$r['offset'] = 0;
	if ( !isset($r['category']) )
		$r['category'] = '';
	if ( !isset($r['orderby']) )
		$r['orderby'] = 'post_date';
	if ( !isset($r['order']) )
		$r['order'] = 'DESC';
 
	$now = current_time('mysql');
 
	$posts = $wpdb->get_results(
		"SELECT DISTINCT * FROM $wpdb->posts " .
		( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
		" WHERE post_date <= '$now' AND (post_status = 'publish') ".
		( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
		" GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
 
	update_post_caches($posts);
 
	return $posts;
}
 


That suggests to me that if it can't find a value, it'll default to 5.

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)   
 To:  Kenny J (WINGNUTKJ)     
31182.14 In reply to 31182.13 
quote:
The offending function is get_posts() in the wp-includes folder


Is that the name of the file? I'm looking at the contents of my wp-includes folder and i don't know what file i should be looking for...

ETA: Right, found the file in question and it says exactly what yours does.

I'll try upgrading to 2.0.5 - probably not tonight, however. I hate messing with databases and just don't feel like attempting that right now.
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)      
31182.15 In reply to 31182.14 

Sorry about that; my mind was kind of mush last night. It's in functions.php, as you've found.

 

I'm not a PHP expert, but I'm wondering if there's some condition where the variable is set to null, or an empty string or something, so it passes the isset() test, but doesn't show up in the string.

 

What say the PHP experts?


Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Matt  
 To:  Kenny J (WINGNUTKJ)     
31182.16 In reply to 31182.15 

Without seeing how the function arguments are handled it's hard to say for sure.

 

But, if that is the only test they're performing on the data then they need to add more. At the moment a variable could be an empty string and it would pass their basic checks.

doohicky

0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Matt     
31182.17 In reply to 31182.16 
I'll have a look deeper into it tonight and try to trace the flow of it. If it was in the querystring as ?var=&someothervar=2 or something, would that pass the isset test?

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)   
 To:  Kenny J (WINGNUTKJ)     
31182.18 In reply to 31182.17 
Out of curiosity, which version of WordPress are you using? 2.0.5?
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)      
31182.19 In reply to 31182.18 
I'm on 2.0.4 just now. I've not got round to updating to the new one yet.

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Kenny J (WINGNUTKJ)  
 To:  Jo (JELLS)      
31182.20 In reply to 31182.18 
Oh and:

quote: Them
What’s new? We have about 50 or so bugfixes, which you can review on our dev tracker here, mostly minor bug fixes around feeds, custom fields, and internationalization.


Could be what you're after...

Kenny
The Wisdom of YouTube comments:
Bright Eyes - When The President Talks To God
Not bad. I thought this song might be anti-God, but it seems more to be against the president, which is cool by me.
0/0
 Reply   Quote More 

 From:  Jo (JELLS)   
 To:  Kenny J (WINGNUTKJ)     
31182.21 In reply to 31182.20 
Yeah... noticed that last night. I will get around to it... just a question of time more than anything else.
0/0
 Reply   Quote More 

 From:  Matt  
 To:  Kenny J (WINGNUTKJ)     
31182.22 In reply to 31182.17 
The isset() function is very similar to empty() except it can be used to tell if a variable is actually empty or if it contains a null char where as the empty() function cannot.

Even though PHP doesn't do explicit types you can still check the variable type and the data it contains using built in functions like is_numeric(), is_bool(), etc.

doohicky

0/0
 Reply   Quote More 

Reply to All    
 

1–20  21–22

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats