When using node_load no xmlsitemap info is added. I have a use case where I'm sending this info using drupal services and its not included in the output. More specifically Im using the deploy module to stage content then send it to a production site.

Comments

erichomanchuk created an issue. See original summary.

erichomanchuk’s picture

Status: Needs review » Needs work

The last submitted patch, 2: add-xmlsitemap-data-node-load-2603662-1-D7.patch, failed testing.

erichomanchuk’s picture

So Ive needed to make a few more changes to get this to work with deploy module. So basically the patch adds in a xmlsitemap_node_create_link on node load. Then I'm able to export the xmlsitemap data using services.

When I pushed using deploy If the nid didn't exactly match then the update or create didn't work. So I moved the nid for the xmlsitemap data out of the array merge and added it to similar volatile variables. As the loc was set correct but nid wrong. This fixed my issue as the nid's being the same are not guaranteed when using deploy.

The last issue I couldn't really figure out is the testing failed for the access check on line 70 of the node tests XMLSitemapNodeFunctionalTest->testNodeSettings(). When the node had its status set to FALSE the xmlsitemap_link_load was still reading access true when it should be false. In the end I just commented out using the cache of the user rights which fixed the problem.

erichomanchuk’s picture

Status: Needs work » Needs review
erichomanchuk’s picture

Just fixing accidentally changing status from TRUE to 1 in the test.

kasey_mk’s picture

Thanks, this was very helpful. It let me add the following to a hook_node_presave function, to exclude nodes with a particular field value:

if ($node->field_branding['und'][0]['tid'] == 34) {
      $node->xmlsitemap['status'] = 0;
      $node->xmlsitemap['status_override'] = 1;
    }
chris matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 3 year old patch in #6 to xmlsitemap_node.module does not apply to the latest xmlsitemap 7.x-2.x-dev and if still applicable needs a reroll.

Checking patch xmlsitemap_node/xmlsitemap_node.module...
Hunk #1 succeeded at 84 (offset 39 lines).
Hunk #2 succeeded at 238 (offset 49 lines).
error: while searching for:
  //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;
  $node->xmlsitemap['access'] = $node->nid ? xmlsitemap_node_view_access($node, drupal_anonymous_user()) : 1;

error: patch failed: xmlsitemap_node/xmlsitemap_node.module:201
error: xmlsitemap_node/xmlsitemap_node.module: patch does not apply