security update for uuid xmlsitemap file_field_path
This commit is contained in:
81
sites/all/modules/xmlsitemap/xmlsitemap_node/README.txt
Normal file
81
sites/all/modules/xmlsitemap/xmlsitemap_node/README.txt
Normal file
@@ -0,0 +1,81 @@
|
||||
CONTENTS OF THIS FILE
|
||||
---------------------
|
||||
|
||||
* Introduction
|
||||
* Requirements
|
||||
* Recommended modules
|
||||
* Installation
|
||||
* Configuration
|
||||
* Maintainers
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
------------
|
||||
|
||||
The XML sitemap node module, part of the XML sitemap
|
||||
(https://www.drupal.org/project/xmlsitemap) package, enables content nodes to
|
||||
be in the sitemap. The XML sitemap module creates a sitemap that conforms to
|
||||
the sitemaps.org specification. This helps search engines to more intelligently
|
||||
crawl a website and keep their results up to date.
|
||||
|
||||
* For a full description of the module visit:
|
||||
https://www.drupal.org/project/xmlsitemap
|
||||
|
||||
* To submit bug reports and feature suggestions, or to track changes visit:
|
||||
https://www.drupal.org/project/issues/xmlsitemap
|
||||
|
||||
|
||||
REQUIREMENTS
|
||||
------------
|
||||
|
||||
This module requires the following modules:
|
||||
|
||||
* XML sitemap - (https://www.drupal.org/project/xmlsitemap)
|
||||
|
||||
|
||||
RECOMMENDED MODULES
|
||||
-------------------
|
||||
|
||||
* Ctools - (https://www.drupal.org/project/ctools)
|
||||
* RobotsTxt - (https://www.drupal.org/project/robotstxt)
|
||||
* Site Verification - (https://www.drupal.org/project/site_verify)
|
||||
* Browscap - (https://www.drupal.org/project/browscap)
|
||||
* Vertical Tabs - (https://www.drupal.org/project/vertical_tabs)
|
||||
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
* This is a submodule of the XML sitemap module. Install the XML sitemap module
|
||||
as you would normally install a contributed Drupal module. Visit
|
||||
https://www.drupal.org/node/895232 for further information.
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
-------------
|
||||
|
||||
1. Install the XML sitemap module.
|
||||
2. Enable the XML sitemap module.
|
||||
3. To include nodes in the sitemap, enable the XML sitemap node submodule.
|
||||
4. To add nodes to the sitemap, visit the Edit page of the Content Type which
|
||||
you want to appear on the sitemap.
|
||||
5. Select the XML sitemap horizontal tab.
|
||||
6. Under "Inclusion" change "Excluded" to become "Included". Save.
|
||||
7. If enabled, all content of the specific node type will be included.
|
||||
Individual nodes can be excluded on their specific node edit page.
|
||||
8. Once that is all complete, go to Configurations --> Search and Metadata -->
|
||||
XML sitemap.
|
||||
9. Select the Rebuild Links tab in the upper right.
|
||||
10. Select on "Rebuild sitemap" even if the message says that you do not need
|
||||
to.
|
||||
11. Now you're taken back to the config page which shows you the link to your
|
||||
XML sitemap which you can select and confirm that pages have been added.
|
||||
|
||||
|
||||
MAINTAINERS
|
||||
-----------
|
||||
|
||||
* Andrei Mateescu (amateescu) - https://www.drupal.org/u/amateescu
|
||||
* Dave Reid - https://www.drupal.org/u/dave-reid
|
||||
* Juampy NR (juampynr) - https://www.drupal.org/u/juampynr
|
||||
* Tasya Rukmana (tadityar) - https://www.drupal.org/u/tadityar
|
@@ -3,13 +3,10 @@ description = Adds content links to the sitemap.
|
||||
package = XML sitemap
|
||||
core = 7.x
|
||||
dependencies[] = xmlsitemap
|
||||
files[] = xmlsitemap_node.module
|
||||
files[] = xmlsitemap_node.install
|
||||
files[] = xmlsitemap_node.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-05-25
|
||||
version = "7.x-2.3"
|
||||
; Information added by Drupal.org packaging script on 2018-10-09
|
||||
version = "7.x-2.6"
|
||||
core = "7.x"
|
||||
project = "xmlsitemap"
|
||||
datestamp = "1464191061"
|
||||
|
||||
datestamp = "1539120486"
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default file for XML sitemap node.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_entity_info_alter().
|
||||
*/
|
||||
@@ -17,7 +22,32 @@ function xmlsitemap_node_entity_info_alter(array &$entity_info) {
|
||||
* Process old nodes not found in the {xmlsitemap} table.
|
||||
*/
|
||||
function xmlsitemap_node_cron() {
|
||||
xmlsitemap_node_xmlsitemap_index_links(xmlsitemap_var('batch_limit'));
|
||||
$limit = xmlsitemap_var('batch_limit');
|
||||
|
||||
// Process nodes that have been queued in hook_node_update().
|
||||
$queue = DrupalQueue::get('xmlsitemap_node');
|
||||
while ($limit > 0 && $item = $queue->claimItem()) {
|
||||
$limit--;
|
||||
try {
|
||||
$node = node_load($item->data);
|
||||
// The node could have been deleted in the meantime, skip XML sitemap
|
||||
// updates in this case.
|
||||
if ($node) {
|
||||
$link = xmlsitemap_node_create_link($node);
|
||||
xmlsitemap_link_save($link, array($link['type'] => $node));
|
||||
}
|
||||
$queue->deleteItem($item);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// In case of exception log it and leave the item in the queue
|
||||
// to be processed again later.
|
||||
watchdog_exception('xmlsitemap_node', $e);
|
||||
}
|
||||
}
|
||||
|
||||
// Add nodes that are missing from the {xmlsitemap} table.
|
||||
// This catches nodes that were created prior to this module being enabled.
|
||||
xmlsitemap_node_xmlsitemap_index_links($limit);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,14 +63,23 @@ function xmlsitemap_node_xmlsitemap_index_links($limit) {
|
||||
/**
|
||||
* Process node sitemap links.
|
||||
*
|
||||
* @param $nids
|
||||
* @param array $nids
|
||||
* An array of node IDs.
|
||||
*/
|
||||
function xmlsitemap_node_xmlsitemap_process_node_links(array $nids) {
|
||||
$nodes = node_load_multiple($nids);
|
||||
foreach ($nodes as $node) {
|
||||
$link = xmlsitemap_node_create_link($node);
|
||||
xmlsitemap_link_save($link, array($link['type'] => $node));
|
||||
// Load no more than 15 nodes at a time.
|
||||
if (count($nids) >= 1) {
|
||||
$nids_chunks = array_chunk($nids, 15);
|
||||
foreach ($nids_chunks as $chunk) {
|
||||
$nodes = node_load_multiple($chunk);
|
||||
foreach ($nodes as $node) {
|
||||
$link = xmlsitemap_node_create_link($node);
|
||||
xmlsitemap_link_save($link, array($link['type'] => $node));
|
||||
}
|
||||
// Flush each entity from the load cache after processing, to avoid
|
||||
// exceeding PHP memory limits if $nids is large.
|
||||
entity_get_controller('node')->resetCache($chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +94,15 @@ 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_save($link, array($link['type'] => $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 checking
|
||||
// node access permissions and process the sitemap link during cron.
|
||||
$queue = DrupalQueue::get('xmlsitemap_node');
|
||||
$queue->createItem($node->nid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +116,7 @@ function xmlsitemap_node_node_delete(stdClass $node) {
|
||||
* Implements hook_comment_update().
|
||||
*/
|
||||
function xmlsitemap_node_comment_update(stdClass $comment) {
|
||||
if ($node = node_load($comment->nid, NULL, TRUE)) {
|
||||
if ($node = entity_load_unchanged('node', $comment->nid)) {
|
||||
xmlsitemap_node_node_update($node);
|
||||
}
|
||||
}
|
||||
@@ -126,6 +172,8 @@ function xmlsitemap_node_form_node_type_form_alter(array &$form, array $form_sta
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*
|
||||
* @codingStandardsIgnoreLine
|
||||
*
|
||||
* Add the XML sitemap individual link options for a node.
|
||||
*
|
||||
* @see xmlsitemap_add_form_link_options()
|
||||
@@ -140,9 +188,10 @@ function xmlsitemap_node_form_node_form_alter(array &$form, array &$form_state)
|
||||
/**
|
||||
* Fetch all the timestamps for when a node was changed.
|
||||
*
|
||||
* @param $node
|
||||
* @param object $node
|
||||
* A node object.
|
||||
* @return
|
||||
*
|
||||
* @return array
|
||||
* An array of UNIX timestamp integers.
|
||||
*/
|
||||
function xmlsitemap_node_get_timestamps(stdClass $node) {
|
||||
@@ -164,7 +213,7 @@ function xmlsitemap_node_get_timestamps(stdClass $node) {
|
||||
*
|
||||
* The link will be saved as $node->xmlsitemap.
|
||||
*
|
||||
* @param $node
|
||||
* @param object $node
|
||||
* A node object.
|
||||
*/
|
||||
function xmlsitemap_node_create_link(stdClass $node) {
|
||||
@@ -195,11 +244,6 @@ function xmlsitemap_node_create_link(stdClass $node) {
|
||||
$node->xmlsitemap['changefreq'] = $node->nid ? xmlsitemap_calculate_changefreq($timestamps) : 0;
|
||||
$node->xmlsitemap['changecount'] = $node->nid ? count($timestamps) - 1 : 0;
|
||||
|
||||
// Node access must be reset since it a user may have changed published status, etc.
|
||||
//$access = &drupal_static('node_access');
|
||||
//unset($access[0][$node->nid]);
|
||||
//node_access_acquire_grants($node);
|
||||
|
||||
// The following values must always be checked because they are volatile.
|
||||
$node->xmlsitemap['loc'] = $uri['path'];
|
||||
$node->xmlsitemap['lastmod'] = count($timestamps) ? max($timestamps) : 0;
|
||||
@@ -212,16 +256,18 @@ function xmlsitemap_node_create_link(stdClass $node) {
|
||||
/**
|
||||
* Determine whether a user may view the specified node.
|
||||
*
|
||||
* @param $node
|
||||
* @param object $node
|
||||
* The node object on which the operation is to be performed, or node type
|
||||
* (e.g. 'forum') for "create" operation.
|
||||
* @param $account
|
||||
* @param object $account
|
||||
* Optional, a user object representing the user for whom the operation is to
|
||||
* be performed. Determines access for a user other than the current user.
|
||||
* @return
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the operation may be performed, FALSE otherwise.
|
||||
*
|
||||
* This is for all intesive purposes a copy of Drupal 7's node_access() function.
|
||||
* This is for all intesive purposes a copy of Drupal 7's node_access()
|
||||
* function.
|
||||
*/
|
||||
function xmlsitemap_node_view_access($node, $account = NULL) {
|
||||
global $user;
|
||||
@@ -241,8 +287,7 @@ function xmlsitemap_node_view_access($node, $account = NULL) {
|
||||
|
||||
// $node may be either an object or a node type. Since node types cannot be
|
||||
// an integer, use either nid or type as the static cache id.
|
||||
//$cid = is_object($node) ? $node->nid : $node;
|
||||
|
||||
// $cid = is_object($node) ? $node->nid : $node;
|
||||
// If we've already checked access for this node, user and op, return from
|
||||
// cache.
|
||||
if (isset($rights[$account->uid][$node->nid])) {
|
||||
@@ -294,7 +339,8 @@ function xmlsitemap_node_view_access($node, $account = NULL) {
|
||||
$query->condition($nids);
|
||||
$query->range(0, 1);
|
||||
|
||||
// Fetch the node grants and allow other modules to alter them (D7 backport).
|
||||
// Fetch the node grants and allow other modules to alter them
|
||||
// (D7 backport).
|
||||
$grants = &drupal_static(__FUNCTION__ . ':grants', array());
|
||||
if (!isset($grants[$account->uid][$op])) {
|
||||
// Indicate that this is our special function in the grants.
|
||||
|
@@ -5,10 +5,30 @@
|
||||
* Unit tests for the xmlsitemap_node module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Node Functional Test.
|
||||
*/
|
||||
class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
|
||||
/**
|
||||
* Normal User.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
protected $normal_user;
|
||||
|
||||
/**
|
||||
* Nodes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $nodes = array();
|
||||
|
||||
/**
|
||||
* Get Info.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'XML sitemap node',
|
||||
@@ -17,21 +37,44 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
}
|
||||
|
||||
function setUp($modules = array()) {
|
||||
/**
|
||||
* Setup.
|
||||
*/
|
||||
public function setUp($modules = array()) {
|
||||
$modules[] = 'xmlsitemap_node';
|
||||
$modules[] = 'comment';
|
||||
parent::setUp($modules);
|
||||
|
||||
$this->admin_user = $this->drupalCreateUser(array('administer nodes', 'bypass node access', 'administer content types', 'administer xmlsitemap'));
|
||||
$this->normal_user = $this->drupalCreateUser(array('create page content', 'edit any page content', 'access content', 'view own unpublished content'));
|
||||
$this->admin_user = $this->drupalCreateUser(array(
|
||||
'administer nodes',
|
||||
'bypass node access',
|
||||
'administer content types',
|
||||
'administer xmlsitemap',
|
||||
));
|
||||
$this->normal_user = $this->drupalCreateUser(array(
|
||||
'create page content',
|
||||
'edit any page content',
|
||||
'access content',
|
||||
'view own unpublished content',
|
||||
));
|
||||
xmlsitemap_link_bundle_settings_save('node', 'page', array('status' => 1, 'priority' => 0.5));
|
||||
}
|
||||
|
||||
function testNodeSettings() {
|
||||
/**
|
||||
* Node Settings.
|
||||
*/
|
||||
public function testNodeSettings() {
|
||||
$body_field = 'body[' . LANGUAGE_NONE . '][0][value]';
|
||||
|
||||
$node = $this->drupalCreateNode(array('status' => FALSE, 'uid' => $this->normal_user->uid));
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 0, 'status' => 1, 'priority' => 0.5, 'status_override' => 0, 'priority_override' => 0));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 0,
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
'status_override' => 0,
|
||||
'priority_override' => 0,
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->normal_user);
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
@@ -44,7 +87,14 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText('Basic page Test node title has been updated.');
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 0, 'status' => 1, 'priority' => 0.5, 'status_override' => 0, 'priority_override' => 0));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 0,
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
'status_override' => 0,
|
||||
'priority_override' => 0,
|
||||
));
|
||||
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
@@ -58,7 +108,14 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText('Basic page Test node title has been updated.');
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 1, 'status' => 0, 'priority' => 0.9, 'status_override' => 1, 'priority_override' => 1));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 1,
|
||||
'status' => 0,
|
||||
'priority' => 0.9,
|
||||
'status_override' => 1,
|
||||
'priority_override' => 1,
|
||||
));
|
||||
|
||||
$edit = array(
|
||||
'xmlsitemap[status]' => 'default',
|
||||
@@ -67,16 +124,24 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertText('Basic page Test node title has been updated.');
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 0, 'status' => 1, 'priority' => 0.5, 'status_override' => 0, 'priority_override' => 0));
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 0,
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
'status_override' => 0,
|
||||
'priority_override' => 0,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the content type settings.
|
||||
*/
|
||||
function testTypeSettings() {
|
||||
public function testTypeSettings() {
|
||||
$this->drupalLogin($this->admin_user);
|
||||
|
||||
$node_old = $this->drupalCreateNode();
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array('status' => 1, 'priority' => 0.5));
|
||||
|
||||
$edit = array(
|
||||
@@ -87,6 +152,7 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
$this->assertText('The content type Basic page has been updated.');
|
||||
|
||||
$node = $this->drupalCreateNode();
|
||||
$this->cronRun();
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('status' => 0, 'priority' => 0.0));
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array('status' => 0, 'priority' => 0.0));
|
||||
|
||||
@@ -98,9 +164,18 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
$this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
|
||||
$this->assertText('Changed the content type of 2 posts from page to page2.');
|
||||
$this->assertText('The content type Basic page has been updated.');
|
||||
$this->cronRun();
|
||||
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('subtype' => 'page2', 'status' => 1, 'priority' => 0.5));
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array('subtype' => 'page2', 'status' => 1, 'priority' => 0.5));
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'subtype' => 'page2',
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
));
|
||||
$this->assertSitemapLinkValues('node', $node_old->nid, array(
|
||||
'subtype' => 'page2',
|
||||
'status' => 1,
|
||||
'priority' => 0.5,
|
||||
));
|
||||
$this->assertEqual(count(xmlsitemap_link_load_multiple(array('type' => 'node', 'subtype' => 'page'))), 0);
|
||||
$this->assertEqual(count(xmlsitemap_link_load_multiple(array('type' => 'node', 'subtype' => 'page2'))), 2);
|
||||
|
||||
@@ -112,7 +187,7 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
/**
|
||||
* Test the import of old nodes via cron.
|
||||
*/
|
||||
function testCron() {
|
||||
public function testCron() {
|
||||
$limit = 5;
|
||||
variable_set('xmlsitemap_batch_limit', $limit);
|
||||
|
||||
@@ -127,17 +202,21 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
|
||||
// Clear all the node link data so we can emulate 'old' nodes.
|
||||
db_delete('xmlsitemap')
|
||||
->condition('type', 'node')
|
||||
->execute();
|
||||
->condition('type', 'node')
|
||||
->execute();
|
||||
|
||||
// Run cron to import old nodes.
|
||||
xmlsitemap_node_cron();
|
||||
|
||||
for ($i = 1; $i <= ($limit + 1); $i++) {
|
||||
$node = array_pop($nodes);
|
||||
$node = array_shift($nodes);
|
||||
if ($i <= $limit) {
|
||||
// The first $limit nodes should be inserted.
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array('access' => 1, 'status' => 1, 'lastmod' => $node->changed));
|
||||
$this->assertSitemapLinkValues('node', $node->nid, array(
|
||||
'access' => 1,
|
||||
'status' => 1,
|
||||
'lastmod' => $node->changed,
|
||||
));
|
||||
}
|
||||
else {
|
||||
// Any beyond $limit should not be in the sitemap.
|
||||
@@ -145,4 +224,5 @@ class XMLSitemapNodeFunctionalTest extends XMLSitemapTestHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user