This is related to #383688: path not being set

Node paths are not being maintained on imported content when the PathAuto module is enabled, even with the option "Reset URL path" disabled in the settings.

I'll try to get a patch submitted a later tonight.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danielb’s picture

Status: Active » Closed (cannot reproduce)

Unfortunately I cannot identify the problem from the information given. If you can supply that patch or explain how Node Export is doing something incorrectly, please reopen the issue.

shawn_smiley’s picture

Status: Closed (cannot reproduce) » Needs review
FileSize
896 bytes

Sorry about the vagueness of my report.

Here are the details on how to reproduce the issue:

Environment:
Drupal 6.19
node_export 2.x-dev
pathauto 1.5
token 1.15

Steps to reproduce

  1. Configure pathauto with a unique URL naming scheme(i.e. I used "page/[title-raw]" and "story/[title-raw]" for page and story types)
  2. Create some content with a mix of auto-generated and manually generated URLs
  3. Configure node export to bulk export to a file
  4. Go to the content screen and export all content
  5. Delete all content on the site
  6. Change the URL alias rules to something else
  7. Configure node export to not reset the URL path on import (option not checked)
  8. Import the exported content from above

Results
All imported nodes have their URL alias's cleared and regenerated using the new pathauto alias rules regardless of the "Clear URLs" setting on the configuration screen.

The expected result was that the nodes would keep their original paths after the import.

Fix
I've attached a patch that adds the property "pathauto_perform_alias=FALSE" to the node being imported if the option "Reset Path" on the configuration screen is not set.

sun’s picture

+++ node_export.module	3 Nov 2010 06:05:20 -0000
@@ -517,6 +517,10 @@ function node_export_import($node_code, 
+        if (module_exists('pathauto'))   {
+          $reset_path = variable_get('node_export_reset_path_'. $new_node->type, 1);
+          if (!$reset_path) $new_node->pathauto_perform_alias = FALSE;
+        }

Various coding style issues, see http://drupal.org/coding-standards

Additionally, this seems to affect bulk exports/imports only?

Powered by Dreditor.

Paul_Gregory’s picture

I was having the same problem with a clean Drupal install. I applied the patch from #3 which seems to have solved the problem. Good work Shawn_Smiley!

danielb’s picture

Try this one, It should be the same logic but in a different place where it will affect all imports.

I don't like to hack in support for contrib modules, but pathauto not being in core is surely a clerical oversight.

sun’s picture

Status: Needs review » Needs work
+++ node_export.module	30 Nov 2010 00:36:40 -0000
@@ -821,6 +821,10 @@ function node_export_node_clone($origina
+    else if (module_exists('pathauto')) {

No space between else and if.

+++ node_export.module	30 Nov 2010 00:36:40 -0000
@@ -821,6 +821,10 @@ function node_export_node_clone($origina
+      // Maintain node paths with pathauto.
+      $node->pathauto_perform_alias = FALSE;

Either the comment should state "Retain" instead of "Maintain", or FALSE should be TRUE (the latter being unlikely).

Powered by Dreditor.

danielb’s picture

Thanks sun - gets confusing working on various projects with different standards! I've made the comment clearer, and corrected the else if.

danielb’s picture

Status: Needs work » Needs review
Paul_Gregory’s picture

I tested the patch from #7 in a clean 6.x-2.x-dev and it works nicely.

sun’s picture

Status: Needs review » Reviewed & tested by the community

@danielb: Exactly for this reason, there is only one standard in Drupal: http://drupal.org/coding-standards

Thanks! Didn't test, but the patch makes sense now.

shawn_smiley’s picture

Thanks danielb and everyone else. I'm embarrassed by the non-standards code. Sorry about that.

danielb’s picture

@sun No, I meant projects other than Drupal, particularly PHP stuff at work. And even with drupal, 3+ years ago when I actually learnt how to create drupal modules; the standards and typical coding practices in the tutorials and modules I learnt from were a little different. Not to mention my head is filled with other programming languages that look similar and it all gets a bit muddled up at times.

danielb’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.