Project

General

Profile

Actions

Bug #432

closed

Fix standard wp_cron

Added by Boone Gorges over 13 years ago. Updated about 13 years ago.

Status:
Resolved
Priority name:
Low
Assignee:
Category name:
WordPress (misc)
Target version:
Start date:
2010-12-06
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

For some reason, wp-cron doesn't work right on the production server (or cdev, which is on the same VM) unless I use ALTERNATE_WP_CRON. I traced it a bit and the process gets at least as far as the wp_remote_post() at the end of spawn_cron(). I didn't dig any further.

Ron, do you have any idea how to troubleshoot this? I think it's only come up with WP 3.0.x.

Actions #1

Updated by Ron Rennick over 13 years ago

There were cron issues in 3.0. Does cron not work at all on sub sites?

Actions #2

Updated by Boone Gorges over 13 years ago

I didn't try any sub sites. Cron does work on the main site, but only through alternate cron or by visiting wp-cron.php directly.

WP 3.0.2, if it makes a difference. It'd make me feel better if I knew it was a core issue, as I did plenty of face-desk maneuvers while testing.

Actions #3

Updated by Ron Rennick over 13 years ago

I'll do some testing. It could be that a plugin is causing it. I don't remember exactly what the cron issue was, but it involved sub sites vs the main one.

Actions #4

Updated by Boone Gorges over 13 years ago

  • Target version changed from 1.1.1 to 1.1.2

Thanks, Ron. Not at all urgent - the ?doing_wp_cron thing just bugs me :)

Actions #5

Updated by Boone Gorges over 13 years ago

  • Target version changed from 1.1.2 to 1.1.3
Actions #6

Updated by Boone Gorges over 13 years ago

  • Target version changed from 1.1.3 to 1.1.4
Actions #7

Updated by Ron Rennick over 13 years ago

I scheduled a post in my local dev copy & it published ok. Is there something in particular that isn't working?

Actions #8

Updated by Boone Gorges over 13 years ago

Email digests (using wp-content/plugins/buddypress-group-email-subscription) aren't sent when ALTERNATE_WP_CRON is off. It's possible that the problem is with the way that the plugin schedules events, but it's strange that it works with alternate cron. It could be a problem further up the cron chain, though, but I have no idea how to troubleshoot that.

Actions #9

Updated by local admin over 13 years ago

I can speak about the OS crontabs, Boone.

Actions #10

Updated by Boone Gorges over 13 years ago

André - wp cron is not truly cron - it fakes it by testing on page load to see whether a certain time has passed and if so, then firing an event. Though maybe it's worthwhile thinking about whether it makes sense to move some of these processes to a real cron event.

Actions #11

Updated by Ron Rennick over 13 years ago

@Boone - did cron work in cdev with MU 2.9.X?

Actions #12

Updated by Ron Rennick over 13 years ago

I just pushed a change into master. In the digest email, no email from values were being passed to the digest email process.

Since the digest runs once a week. I'm planning on writing a plugin that will store the results of any cron job on the main site in the database so we can examine afterward.

Actions #13

Updated by Ron Rennick over 13 years ago

I just pushed a plugin into master that will log unsuccessful wp_remote_post calls on the main site.

Actions #14

Updated by Boone Gorges over 13 years ago

Thanks for all this so far, Ron.

I pulled the plugin to cdev to test in the same environment as the production server. The entries in the sitemeta are giving an error. Here are two consecutive keys, which I take to be the request (http_api_debug on the way out) and the response (http_api_debug on the way in). We're getting a 401, but it's not a WP page. Does that suggest there's a server config issue at work here?

4222 1 cac_http_WP_Http_Curl1292503613 a:4:{s:7:"headers";a:0:{}s:4:"body";s:0:"";s:8:"response";a:2:{s:4:"code";s:0:"";s:7:"message";s:0:"";}s:7:"cookies";a:0:{}}
4223 1 cac_http_WP_Http_Curl1292503630 a:4:{s:7:"headers";a:6:{s:4:"date";s:29:"Thu, 16 Dec 2010 12:47:10 GMT";s:6:"server";s:22:"Apache/2.2.3 (Red Hat)";s:16:"www-authenticate";s:29:"Basic realm="Restricted Area"";s:14:"content-length";s:3:"519";s:10:"connection";s:5:"close";s:12:"content-type";s:29:"text/html; charset=iso-8859-1";}s:4:"body";s:519:"<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr>
<address>Apache/2.2.3 (Red Hat) Server at <a href="mailto:root@localhost">cdev.gc.cuny.edu</a> Port 80</address>
</body></html>
";s:8:"response";a:2:{s:4:"code";s:3:"401";s:7:"message";s:12:"Unauthorized";}s:7:"cookies";a:0:{}}
Actions #15

Updated by Ron Rennick over 13 years ago

cdev has the htpass on it. The alternate cron hooks into a browser request where the default one uses a remote call. I suspected that regular cron would not work correctly in cdev because the remote call is not authenticated with apache.

Actions #16

Updated by Boone Gorges over 13 years ago

Ron, is there something that André can do so that apache will allow the remote call that we need? The address being requested is commons.gc.cuny.edu/wp-cron.php, right? (

Actions #17

Updated by Ron Rennick over 13 years ago

I was going to do a bit of research to see if there is a way to exclude certain urls from the authentication requirement.

Actions #18

Updated by Ron Rennick over 13 years ago

Here's an example of excluding a uri from the htpasswd requirement:

http://www.webdeveloper.com/forum/archive/index.php/t-49423.html

Some of it may need to be done in the vhost entry, so I'll leave this one for Boone.

Actions #19

Updated by local admin over 13 years ago

Let me know if I can lend a hand here, ok? I can easily re-conf htttpd.conf if .htaccess doesn't do it.

Actions #20

Updated by Ron Rennick over 13 years ago

Sorry, that link above doesn't explain how to exclude uris from htpasswd. Doing more research.

Actions #21

Updated by Boone Gorges over 13 years ago

André - does the cdev or commons user have read access to the httpd.conf or vhosts file on the Commons box? Ron wants to have a look for debugging.

Actions #22

Updated by local admin over 13 years ago

Yes, Boone. How about I post the .conf to our redmine "files" section or something? Is that private?

Actions #23

Updated by Boone Gorges over 13 years ago

I don't think it's private. Could you put it on Bootcamp or email it to me?

Actions #24

Updated by local admin over 13 years ago

Hmm.. Basecamp is probably not ideal, because then everey time I made changes I'd have to manually upload that via BC's web ui which could be hard to script.
I guess I'll leave it up to you guys, because I believe the file is readable by default. : )

Actions #25

Updated by Boone Gorges over 13 years ago

Ron - André's right, /var/httpd/conf/httpd.conf is readable by the cdev user. Shell in and check it out yourself.

Actions #26

Updated by Boone Gorges over 13 years ago

  • Target version changed from 1.1.4 to 1.1.5
Actions #27

Updated by Boone Gorges over 13 years ago

  • Target version changed from 1.1.5 to 1.1.6
Actions #28

Updated by Boone Gorges over 13 years ago

  • Target version changed from 1.1.6 to 1.1.7
Actions #29

Updated by Ron Rennick over 13 years ago

We should be able to implement this: http://www.askapache.com/htaccess/apache-authentication-in-htaccess.html#allow-conditional to allow cdev to post to itself & allow both cdev's IP and 127.0.0.1 (just in case).

Actions #30

Updated by Boone Gorges over 13 years ago

This looks like a workaround for the fact that cdev is protected by .htpasswd. But regular cron isn't working on the production server either, where there is no such restriction. Am I understanding this correctly?

Actions #31

Updated by Ron Rennick over 13 years ago

Yes, this is just for cdev. We need to get by the password issue so we can see what other errors crop up.

Actions #32

Updated by Boone Gorges over 13 years ago

  • Target version changed from 1.1.7 to 1.1.8
Actions #33

Updated by Ron Rennick over 13 years ago

Is Andre going to do the edits to the httpd.conf? He had offered above, so I was leaving that edit for him. That way he can put whatever notes on it he needs for his own documentation.

Actions #34

Updated by Boone Gorges about 13 years ago

  • Target version changed from 1.1.8 to 1.1.9
Actions #35

Updated by Ron Rennick about 13 years ago

@Andre/Boone - did someone implement the changes I lniked to in http://redmine.gc.cuny.edu/issues/show/432#note-29

Actions #36

Updated by Boone Gorges about 13 years ago

  • Target version changed from 1.1.9 to 1.1.10
Actions #37

Updated by Boone Gorges about 13 years ago

André, can you make the following changes? Because cdev is password protected at the httpd.conf level rather than at .htaccess, I don't believe that I have the access to do so. Presumably there is a Deny/AuthUserFile etc rule like the following somewhere in cdev's Apache configuration; we need 'Allow from' lines like I have inserted below:

Order deny,allow
Deny from all
AuthName "htaccess password prompt"
AuthUserFile /home/askapache.com/.htpasswd
AuthType Basic
Require valid-user
Allow from 146.96.128.200
Allow from 127.0.0.1
Satisfy Any

Actions #38

Updated by local admin about 13 years ago

Boone, more than happy to edit that config. But it's probably better if we move that stanza to the local .htaccess file, so you guys will be able to edit it more freely going forward. What do you think?

Actions #39

Updated by Boone Gorges about 13 years ago

That'd be ideal, André. Please move the whole kit and kaboodle to .htaccess (and make sure allowoverride is set). Also, could you please put .htpasswd in a place where I can read and write it - maybe in /home/cdev?

Thanks!

Actions #40

Updated by local admin about 13 years ago

Will do. I'll let you all know if this breaks anything as best I can.

I believe that's already the current location for the password file, but it was owned by root. I'll change that now.

Actions #41

Updated by local admin about 13 years ago

Ok, looks ok to me, but I don't know/remember the htpasswd. Let me know if it's broken, ok?

Actions #42

Updated by Boone Gorges about 13 years ago

Looks good for now. Thanks, André!

Actions #43

Updated by Ron Rennick about 13 years ago

Worked for me as well :)

@boone, do we need to clean out those cron log records from the DB so we can see the current ones?

Actions #44

Updated by Boone Gorges about 13 years ago

Yup, I just cleared them out. I'm going to start pinging around cdev to try to get one to record.

Actions #45

Updated by Boone Gorges about 13 years ago

Hi Ron,

Sorry for the delay in this - it keeps getting lost in my pile of things to do.

I just checked cdev to see if the messages have been recorded. They have, though I'm not sure what to make of them. Every few hours, a cron response like this is being recorded:
a:4:{s:7:"headers";a:0:{}s:4:"body";s:0:"";s:8:"response";a:2:{s:4:"code";s:0:"";s:7:"message";s:0:"";}s:7:"cookies";a:0:{}}

In other words, the response appears to be empty - no code or anything. Is this the same thing that was happening before? Does this mean that cdev still isn't able to make contact with itself because of htpasswd?

Actions #46

Updated by Ron Rennick about 13 years ago

I've been way too busy as well. I owe you an email I think. I think that response is due to cron not having anything to do. I'll log in a little later and schedule a post.

If the scheduled post works okay we may have to dummy up some group activity so that the email digest has to run.

Actions #47

Updated by Ron Rennick about 13 years ago

The post appears to have published fine. So, we'll have to drum up some activity that triggers the email digest.

Actions #48

Updated by Boone Gorges about 13 years ago

  • Target version changed from 1.1.10 to 1.1.11
Actions #49

Updated by Ron Rennick about 13 years ago

I set myself up with daily digest on http://cdev.gc.cuny.edu/groups/another-test-group-for-forums/. Can we have a few people generate some activity in that group?

Also, I'm assuming mail is running on cdev?

Actions #50

Updated by Boone Gorges about 13 years ago

  • Assignee changed from Ron Rennick to Boone Gorges

I made some upgrades to the email subscription plugin (related to the WP 3.1 Network Admin menu - nothing to do with digests). Then I pulled those most recent changes to cdev and, lo and behold, email digests seem to work. It's possible that there have been other updates to the plugin since our last update that made it happen. In any case, when I release 1.1.11 I will remove the alternate cron declaration for the production server and test to see whether I can receive any emails. If so, then this ticket will (miraculously) have been solved.

Reassigning to myself for the moment so that I don't forget to do it.

Actions #51

Updated by Boone Gorges about 13 years ago

  • Status changed from Assigned to Resolved

Woo hoo! It works on the production server!

Ron - thanks a million for all your patience and help with this. I wish I knew what ultimately solved it, but in any case, it's working now. (Plus, now we have a handy script for logging WP_Http errors for future use)

Actions #52

Updated by Ron Rennick about 13 years ago

W00t :) Nice to see that fixed even though we don't know how we fixed it.

Do you want that cron debug plugin put up on wp.org/extend? Also, don't forget to disable/remove that plugin.

Actions #53

Updated by Boone Gorges about 13 years ago

Yup, I disabled the plugin in https://github.com/castiron/cac/commit/beea18a059d2d2b16164b7c6d3a23962d5f6a9ae (just commented out the add_action)

Great idea about putting it in the repo. When you get a chance, could you take care of that? I think it could go pretty much as-is - if anyone out there was feeling really ambitious, they could build an admin panel for it, but I don't think that's necessary.

Actions #54

Updated by Ron Rennick about 13 years ago

I'll request the repo over the weekend and upload it sometime next week.

Actions #55

Updated by Matt Gold about 13 years ago

Nice work, guys. Thanks.

Actions #56

Updated by Ron Rennick about 13 years ago

http://wordpress.org/extend/plugins/cron-debug-log/ - Should be available in a few minutes.

Actions

Also available in: Atom PDF