Recent Topics

1 Oct 22, 2008 22:22    

Hi,

I am posting because I have just noticed that my Twitterlution plugin no longer works with b2evolution 2.4.5 and I was hoping that someone could spot something obvious that I am missing. The plugin worked fine in 2.4.2 but now when I have the plugin active and try to save a post the post gets saved to the db but the screen does not return to the post list. I am assuming that no pings happen at all but I am not sure. I know the ping for my plugin doesn't happen. The ping function is as follows:


$title =  $params['Item']->dget('title', 'xml');
$perm_url = $params['Item']->get_permanent_url();
$update_text = $this->UserSettings->get( 'twitterlution_update_text' );
$status = "$update_text '$title' - $perm_url";
$url = "http://twitter.com/statuses/update.xml";
$username = $this->UserSettings->get( 'twitterlution_username' );
$password = $this->UserSettings->get( 'twitterlution_password' );

$session = curl_init();
curl_setopt ( $session, CURLOPT_URL, $url );
curl_setopt ( $session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
curl_setopt ( $session, CURLOPT_HEADER, false );
curl_setopt ( $session, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ( $session, CURLOPT_USERPWD, "$username:$password" );
curl_setopt ( $session, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $session, CURLOPT_POST, 1);
curl_setopt ( $session, CURLOPT_POSTFIELDS,"source=twitterlution&status=" . urlencode($status));
$result = curl_exec ( $session );
curl_close( $session );
// check for success or failure
if (empty($result)) {
		return false;
} else {
	return true;
}

I am really not sure where to start looking as the release note for 2.4.5 said all plugins should be compatible. Obviously I have done something wrong in my plugin :-)

Any help would be greatly appreciated.
Thanks
Lee

2 Oct 22, 2008 22:38

Hi Iturner,

I don't see any error here and yes, there is no change in the core that would explain your plugin not to function anymore.
Try to debug by echoing some variables (or use pre_dump( $foo ) where $foo can have any type including array and Object ) until you find where it halts.

Good luck

3 Oct 23, 2008 14:07

Hi Afwas

Many thanks for your reply. I am glad it isn't just me going mad :-) I have investigated further and it seems that after I have tried to save the post (which does happen) and then the screen stays blank I can go back to the dashboard and load up the post, click on save and the whole thing works as it should. The pings happen with no problems when I save it the second time including my plugin so I am not sure whether this is a problem with my plugin or not any more. Any ideas?? Has there been any change to the way posts are saved that would cause my plugin to fail if a piece of data wasn't there ?

I'll start down the debugging route and see what I find.

Many thanks
Lee

4 Oct 24, 2008 14:10

Hi guys

I think I have found the problem but I am not sure whether it is a problem with my plugin given that this worked in previous versions (2.4.2). It seems to be a problem with the getting of the permanent url for the post. In my plugin I get the permanent url to use in the twitter post to obviously make it easy for people to link directly to the information they want. This was done using the following:


$title =  $params['Item']->dget('title', 'xml');
$perm_url = $params['Item']->get_permanent_url();
$update_text = $this->UserSettings->get( 'twitterlution_update_text' );
$status = "$update_text '$title' - $perm_url"; 

This didn't work in 2.4.5 and caused a blank page after the saving of the post during the execution of the pings. I have now changed this to the following:


$item_Blog = $params['Item']->get_Blog();
$title =  $params['Item']->dget('title', 'xml');
//$perm_url = $params['Item']->get_permanent_url();
$url = $item_Blog->get('url');
$update_text = $this->UserSettings->get( 'twitterlution_update_text' );
$status = "$update_text '$title' - $url";

As you can see I am now just getting the url of the blog and not the url of the post. This is not ideal because if someone finds the twitter post a few months down the line they will just link through to the blog and then have to search through months of posts to get to the one referenced in the twitter post.

I am open to suggestions on this one. Is this a problem with the core ? Maybe it is the combination of the settings that I have in my 2.4.5 blog over the blogs I haven't upgraded yet that are still running 2.4.2. I did change the SEO settings in my 2.4.5 blog that I don't think I changed in my 2.4.2 blogs but that could just be a red herring.

Many thanks
Lee


Form is loading...