Skip to content
Snippets Groups Projects
Commit cd8513e3 authored by elliotttf's avatar elliotttf Committed by Dave Reid
Browse files

Issue #870556: Fixed PuSH verifications run before the subscription records have been saved."

parent 4c0e196f
No related branches found
No related tags found
No related merge requests found
......@@ -395,6 +395,15 @@ function feeds_page_access() {
* Implements hook_exit().
*/
function feeds_exit() {
// Process any pending PuSH subscriptions.
$jobs = feeds_get_subscription_jobs();
foreach ($jobs as $job) {
if (!isset($job['fetcher']) || !isset($job['source'])) {
continue;
}
$job['fetcher']->subscribe($job['source']);
}
if (drupal_static('feeds_log_error', FALSE)) {
watchdog('feeds', 'Feeds reported errors, visit the Feeds log for details.', array(), WATCHDOG_ERROR, 'admin/reports/dblog/feeds');
}
......@@ -1006,3 +1015,36 @@ function feeds_valid_url($url, $absolute = FALSE) {
return (bool) preg_match("/^(?:[\w#!:\.\?\+=&@$'~*,;\/\(\)\[\]\-]|%[0-9a-f]{2})+$/i", $url);
}
}
/**
* Registers a feed subscription job for execution on feeds_exit().
*
* @param array $job
* Information about a new job to queue; or if set to NULL (default), leaves
* the current queued jobs unchanged.
*
* @return
* An array of subscribe jobs to process.
*
* @see feeds_exit()
* @see feeds_get_subscription_jobs()
*/
function feeds_set_subscription_job(array $job = NULL) {
$jobs = &drupal_static(__FUNCTION__, array());
if (isset($job)) {
$jobs[] = $job;
}
return $jobs;
}
/**
* Returns the list of queued jobs to be run.
*
* @return
* An array of subscribe jobs to process.
*
* @see feeds_set_subscription_job()
*/
function feeds_get_subscription_jobs() {
return feeds_set_subscription_job();
}
......@@ -164,7 +164,15 @@ class FeedsHTTPFetcher extends FeedsFetcher {
*/
public function sourceSave(FeedsSource $source) {
if ($this->config['use_pubsubhubbub']) {
$this->subscribe($source);
// If this is a feeds node we want to delay the subscription to
// feeds_exit() to avoid transaction race conditions.
if ($source->feed_nid) {
$job = array('fetcher' => $this, 'source' => $source);
feeds_set_subscription_job($job);
}
else {
$this->subscribe($source);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment