Commit 8d33ff93 authored by Joseph Zhao's avatar Joseph Zhao Committed by pifagor

Issue #2987125 by Joseph Zhao, sjerdo, mrgoodfellow, Rory Downes,...

Issue #2987125 by Joseph Zhao, sjerdo, mrgoodfellow, Rory Downes, tobybellwood, pifagor, rjw, saurabh-chugh, afinnarn, webservant316: After updating from 7.x-2.3 to 7.x-2.4 Content Inclusion Options NOT Saving
parent da264b2f
......@@ -57,6 +57,24 @@ function hook_xmlsitemap_link_info() {
);
}
/**
* Act on a sitemap link being inserted or updated.
*
* This hook is currently invoked from xmlsitemap_node_node_update() before
* the node sitemap link is saved to the database with revoked access until
* the node permissions are checked in the cron.
*
* @param array $link
* An array with the data of the sitemap link.
* @param array $context
* An optional context array containing data related to the link.
*/
function hook_xmlsitemap_link_presave_alter(array &$link, array $context) {
if ($link['type'] == 'mymodule') {
$link['priority'] += 0.5;
}
}
/**
* Alter the data of a sitemap link before the link is saved.
*
......
......@@ -599,6 +599,26 @@ function xmlsitemap_link_load_multiple(array $conditions = array()) {
return $links;
}
/**
* Presave a sitemap link.
*
* @param array $link
* An array with a sitemap link.
* @param array $context
* An optional context array containing data related to the link.
*/
function xmlsitemap_link_presave(array $link, array $context = array()) {
// Force link access to 0 in presave so that the link is saved with revoked
// access until the node permissions are checked in the cron.
$link['access'] = 0;
// Allow other modules to alter the sitemap link presave.
drupal_alter('xmlsitemap_link_presave', $link, $context);
// Save or update a sitemap link which will be overwritten in Drupal cron job.
xmlsitemap_link_save($link, $context);
}
/**
* Saves or updates a sitemap link.
*
......
......@@ -85,9 +85,13 @@ function xmlsitemap_node_node_insert(stdClass $node) {
* Implements hook_node_update().
*/
function xmlsitemap_node_node_update(stdClass $node) {
// Save a sitemap link with revoked access until the node permissions are
// checked in the cron.
$link = xmlsitemap_node_create_link($node);
xmlsitemap_link_presave($link, array($link['type'] => $node));
// Node access can not be accurately determined in hook_node_update() because
// node grants have not yet been written to the table, so we defer creation of
// a sitemap link and process during cron.
// node grants have not yet been written to the table, so we defer checking
// node access permissions and process the sitemap link during cron.
$queue = DrupalQueue::get('xmlsitemap_node');
$queue->createItem($node->nid);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment