Pathauto 1.3 merged the pathauto_persist module which creates a pathauto_state table to store it's setting for each node (see https://www.drupal.org/node/936222). The setting is loaded with pathauto's hook_entity_load(). But entity_translation ignores this and forces new translations of a node to always have pathauto switched on.

Scenario
In a site with two languages, English and French, a user creates a page in English and turns pathauto off so they can type a custom path. After saving it, they go to add a French translation of the same page...

Expected Behaviour
Pathauto should be turned off.

Actual Behaviour
Pathauto is turned on again, even though they turned it off when they created the English translation.

This patch just removes the bit that overrides pathauto. Also, see my other issue & patch regarding pathauto https://www.drupal.org/node/2743685

I'm using Drupal 7.43, Entity translation 7.x-1.x-dev (May 29, 2016), Pathauto 1.3

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bwaindwain created an issue. See original summary.

bwaindwain’s picture

bwaindwain’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: entity_translation-respect_pathauto_state-2741407-2.patch, failed testing.

bwaindwain’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta5
Status: Needs work » Needs review
bwaindwain’s picture

bwaindwain’s picture

Issue summary: View changes
bwaindwain’s picture

Issue summary: View changes
Nitebreed’s picture

Status: Needs review » Reviewed & tested by the community

I supposed it was possible to have different pathauto settings for lets say an English node and it's French translation (automatic or not), but as I see this isn't the case as the pathauto setting is unique on the node (not unique per language).

In this light, the patch does the right job.

joseph.olstad’s picture

is reasonable expected behavior , thanks.

stefanos.petrakis@gmail.com’s picture

Status: Reviewed & tested by the community » Closed (works as designed)

I don't think this should be changed.

The current code's comment says:

// If a translation is being created and no path alias exists for its
// language, by default an alias needs to be generated. The standard
// behavior is defaulting to FALSE when an entity already exists, hence we
// need to override it here.

This is UX-related logic, and the problem it's trying to solve it the generation of URLs (path)automatically,
without the user having to go through the vertical tabs in order to locate and check the Generate automatic URL alias checkbox.

As it is now:
a) Entities without a URL alias, will get one from pathauto, only if they don't have one, without the user having to do anything
b) On subsequent loading of the form, during edits, the checkbox is unchecked, since there is a URL alias already there. The user is then free to overwrite the pathauto generated alias.

If we go with the suggested code change, when adding a translation, the user always has to go and enter a URL alias, otherwise the translation will not get one. The UX-overhead of unchecking the checkbox is minimal, in comparison to always having to locate the vertical tabs and check that same checkbox.

I am setting this to works-as-designed and will be happy to get some counter-argumentation in case I missed sth important.

bwaindwain’s picture

Good points.

I like you're idea of letting pathauto make urls for new translations.

But... if we go with the suggested patch, the user isn't forced to enter a URL alias when adding a translation. They'll end up with something like /fr/node/123 which will work fine. And, pathauto will be unchecked which is predictable and consistent, which I think makes for good UX.

Hmmm, now I'm undecided.

stefanos.petrakis@gmail.com’s picture

Status: Closed (works as designed) » Active

I see your point too; it seems to me that both cases deserve to be backed up by the implementation.

So, instead of removing the existing logic as suggested in the original patch, I think we should look for a way to extend it or parametrize it in order to be able to cover the case you are describing.

For example:

    if (module_exists('pathauto') && 
      $handler->getSourceLanguage() && 
      variable_get('entity_translation_pathauto_auto_url_generation_' . $entity_type . '_' . $bundle, TRUE)) {
      $entity->path['pathauto'] = TRUE;
    }

And that would allow covering both cases via configuration.
Thoughts?

joseph.olstad’s picture

I agree, sounds like a good plan

stefanos.petrakis@gmail.com’s picture

This can now be handled via configuration, a patch is available over at #3010146: Expose extended ET-specific configuration for pathauto that needs reviewing.
If that goes through, this can be closed as a "Won't fix" since it will then be possible to toggle the pathauto_state default for new translations.

stefanos.petrakis@gmail.com’s picture

Status: Active » Closed (won't fix)

As mentioned before, this is now configurable, for more information, see #3010146: Expose extended ET-specific configuration for pathauto

joseph.olstad’s picture

nice work Stefanos, thanks!