I had the old delicious plugin (4.2??) and it all worked just about.
Downloaded the 4.6.0 one, removed my old module (modules/delicious/*) and installed all the new files. Then added the mysql file to the database. Then set it all up by configuring at administer->settings->delicious with all node types, added a delicious block with user "willwade" and set the number to 20. Lastly enabled it in my account.

Tried firing it off with the cron script but alas nothing. zip. nowt. No errors or warnings just "Cron run completed" in the logs.

see the output (or lack of it) at: http://sourceymonkey.com/delicious

any help much much appreciated!!

thanks!

will

Comments

merlinofchaos’s picture

Assigned: Unassigned » merlinofchaos

Try using mysql to execute this query and tell me the result:

select user, lastupdate, lastcode from delicious_user;

willwade’s picture

running "SELECT user, lastupdate, lastcode
FROM delicious_user" I get one row returned..

user: willwade
lastupdate:
lastcode: 0

by the way my cron script is stuck into cron to run every 10 minutes - not sure if that matters..

thanks

will

breyten’s picture

I'm having the same problems. My cron job runs every 15 minutes.

willwade’s picture

Ok I know where the problem is occuring.. why is another matter:

around line 241 of delicious.module:

  while ($u = db_fetch_object($result)) {

it never executes that line properly - or at least it does and it always returns nothing..

if you change it to (this is brutal hacking - I cant work out drupals logic..)

  while ($u = db_fetch_array($result)) {

the _delicious_update_user($u) does get executed but of course it errors out in that function because it is expecting the object rather than the array..
what to do from here is where I got lost.. back to you mr merlinofchaos :)

debugging is a nightmare in drupal isnt it??!

hth
w

merlinofchaos’s picture

Wow, that's interesting. And very, very weird. I've never seen db_fetch_object fail. And I've never gotten a failure like that.

Sorry I haven't worked on this this week; I've had a nasty cold and haven't had the brain power left to look at this.

Since I can't duplicate that on my system, try this:

Comment out the entirety of the while loop for now (but leave the db_query() statement), and in its place, do this:

$u = db_fetch_object($result);
print "" . var_export($u, true) . "";

Then browse your cron.php page and see what the output is. If it gives you any output at all, stick it back in the while loop, but do the debug printing instead of the _delicious_update_user call.

merlinofchaos’s picture

Oops, forgot to code-tag it.

Err. Rather this

$u = db_fetch_object($result);
print "<code>" . var_export($u, true) . "

";

willwade’s picture

No probs on not working on it - funnily enough the reason why Im looking at it this afternoon is because I have a cold..(and can't stand to think of the work I am meant to be doing..!!)

outputs as expected:

class stdClass {
  var $uid = '1';
  var $name = 'willwade';
  var $user = 'willwade';
  var $pass = '*******';
  var $lastupdate = '';
  var $lastcode = '0';
}

pass of course starred out. That would be just plain silly :)

I had a thought - is it because there is only 1 row returned?? I wouldn't of thought so..

merlinofchaos’s picture

It shouldn't be just because there's one record; I only had one record in my system when testing that.

Do you get the same output within the while loop?

willwade’s picture

... and I meant to say..
it all works in the loop..

looking further is being called
where it is erroring out is around 655

if ($resp->code != 200)
  {
   echo "chheeeeese grommit! the resp code is: ".$resp->code;
    db_query("UPDATE {delicious_user} SET lastcode = $resp->code WHERE uid=$user->uid");
    return 0;
  }

and it prints:

class stdClass {
  var $uid = '1';
  var $name = 'willwade';
  var $user = 'willwade';
  var $pass = 'narfzoik';
  var $lastupdate = '';
  var $lastcode = '0';
}
chheeeeese grommit! the resp code is: 0

0 eh?? mean anything to you?

merlinofchaos’s picture

At the point where it's printing cheeeeese, gromit print a var_export on $resp.

This is one that I have seen on other systems from time to time (but strangely rarely my own), and I think I may not be catching information out of the response. This could be valuable.

Also, when we're done here, you'd best change your password =)

willwade’s picture

im replying to quick:

$resp = _delicious_get_page(DELICIOUS_UPDATE_URL, $user->user, $user->pass);
     echo "chheeeeese wallace! the resp code is". $resp->code."\n\n";

  if (!$resp->code || is_string($resp->code))
	  $resp->code = 0;
  if ($resp->code != 200)
  {
     echo "chheeeeese grommit! the resp code is". $resp->code.'';

    db_query("UPDATE {delicious_user} SET lastcode = $resp->code WHERE uid=$user->uid");
    return 0;
  }

chheeeeese wallace! the resp code is 200

chheeeeese grommit! the resp code is 0

so although it was 200 its getting changed to 0

commenting out

//if (!$resp->code || is_string($resp->code))
//	  $resp->code = 0;

allows the cron to continue. yay.
Intrestingly (and perhaps this should be logged as a new bug) I get a mysql error

user error: Duplicate entry '8-digby' for key 1
query: INSERT INTO delicious_tag (lid, uid, name, synced) VALUES (8, 1, 'digby', 1) in /includes/database.mysql.inc on line 66.

so 1 down, 1 new one to go...

:)

w

willwade’s picture

(im such a muppet re: pass)
this fixes it by the way:

  if (!$resp->code || !is_numeric($resp->code)){ $resp->code = 0; }

of course the other bug is nothing major - the script carries on as normal..
good teamwork :)
w

merlinofchaos’s picture

If the other error happens again, open a new bug on it anyway. IF you can't duplicate it, er, don't bother.

The actual fix is to use intval() -- the reason that line of code was there was in case the response code is non-int, it caused the update to fail. I should've done that in the first place but I must've been sleeping.

Committing to HEAD.

merlinofchaos’s picture

Status: Active » Fixed

Commited to HEAD (and changing status to fixed)

merlinofchaos’s picture

Title: Umm what have I done wrong.. » delicious_cron() not actually doing anything

Changed the title to be something more informative for history and search purposes.

merlinofchaos’s picture

Title: delicious_cron() not actually doing anything » delicious_cron() hook doesn't actually do anything
Category: support » bug
Priority: Normal » Critical

Recreating info because the project disappeared for a few moments, and this was followed up on and lost the project info.

Anonymous’s picture

Status: Fixed » Closed (fixed)