summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/contrib/xmlsitemap/SA-CONTRIB-2018-053-6.x-2.x.patch37
1 files changed, 37 insertions, 0 deletions
diff --git a/common/contrib/xmlsitemap/SA-CONTRIB-2018-053-6.x-2.x.patch b/common/contrib/xmlsitemap/SA-CONTRIB-2018-053-6.x-2.x.patch
new file mode 100644
index 0000000..9a8a3ed
--- /dev/null
+++ b/common/contrib/xmlsitemap/SA-CONTRIB-2018-053-6.x-2.x.patch
@@ -0,0 +1,37 @@
+diff --git a/xmlsitemap_node/xmlsitemap_node.module b/xmlsitemap_node/xmlsitemap_node.module
+index 4a084cc..73abdf5 100644
+--- a/xmlsitemap_node/xmlsitemap_node.module
++++ b/xmlsitemap_node/xmlsitemap_node.module
+@@ -81,8 +81,8 @@ function xmlsitemap_node_nodeapi(stdClass &$node, $op, $a3 = NULL, $a4 = NULL) {
+ switch ($op) {
+ case 'insert':
+ case 'update':
+- $link = xmlsitemap_node_create_link($node);
+- xmlsitemap_link_save($link);
++ // Defer creating and saving the link until the node is fully saved.
++ register_shutdown_function('xmlsitemap_node_create_and_save_link', $node, getcwd());
+ break;
+ case 'delete':
+ xmlsitemap_link_delete('node', $node->nid);
+@@ -236,6 +236,21 @@ function xmlsitemap_node_create_link(stdClass $node) {
+ }
+
+ /**
++ * Create and save a sitemap link from a node.
++ */
++function xmlsitemap_node_create_and_save_link($node, $drupal_root = NULL) {
++ if (!empty($drupal_root)) {
++ // Set the CWD to DRUPAL_ROOT as it is not guaranteed to be the same as it
++ // was in the normal context of execution.
++ // @see _drupal_shutdown_function() from Drupal 7.
++ chdir($drupal_root);
++ }
++
++ $link = xmlsitemap_node_create_link($node);
++ xmlsitemap_link_save($link);
++}
++
++/**
+ * Determine whether a user may view the specified node.
+ *
+ * @param $node