During the update process (replace file) I get an new aliase for every temporary file that is created. The option for automatic URL aliase is not set on the file updated entity. It seems that this aliases are removed after the temp file is deleted by the cron but it is very confusing to me. I thought that the same file gets new aliases every time I update it as you see below.

Created new alias file/nanoz-user-manualpdf for file/1772.
Document nanoZ_user_manual.pdf has been updated.

The first line says a new aliase is created for the file 1772 but as it turns out this is a temp file. The file updated is 445 and gets no new aliase.

Is it neccessary to make a temp file during the update process and if shouldn't they be ignored for aliase creation?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ron_s’s picture

I'm noticing this same issue. The URL aliases admin page is full of duplicate file aliases. Same system and alias URLs, but new entry in the table.

ron_s’s picture

Also, even if this is necessary for the temp file creation process, why isn't the alias being removed when the temp file is removed?

joseph.olstad’s picture

Good questions, recommend searching through the issue queue in both open and all issues for file_entity, this could have several open duplicate issues, there might even be an existing patch alreadu available, start looking in this issue queue. It is often a gold mine.

Also, if you find an improvement or develop an improvement, please share it.

ron_s’s picture

I looked through the entire issue queue, that's what led me to this thread. It's the only post that addresses this issue.

We have some higher priority tasks to focus on at the moment. Just wanted to make sure others were aware.

ron_s’s picture

Title: Unnecessary file aliases when updating the file » Conflict between File Entity and Pathauto Entity modules
Status: Active » Needs review
FileSize
1021 bytes

I have found the issue. File Entity and Pathauto Entity (https://www.drupal.org/project/pathauto_entity) do not respect what the other module is doing in regards to aliases, and therefore duplicates are created. Both modules require patches.

Attached is the patch for File Entity. I will add the one for Pathauto Entity shortly and cross-reference it here.

ron_s’s picture

Here is the patch that is required for Pathauto Entity to respect when File Entity should be responsible for the aliases: https://www.drupal.org/project/pathauto_entity/issues/2991859

joseph.olstad’s picture

Hi ron_s , I had a look at both patches..
so if I applied the patches to both modules, would the correct behavior occur or not?

This is a bit tricky because I am not a maintainer of pathauto so I cannot commit a patch to pathauto. I can only commit the file_entity patch.

if just the file_entity patch is applied, what happens?

joseph.olstad’s picture

reviewed again, I think the file_entity patch is incorrect

Revert your pathauto patch, and use this file_entity patch instead:

+  // Skip processing if pathauto_entity module is being used to manage file aliases.
+  if (module_exists('pathauto_entity')) {
+    $entity_types = variable_get('pathauto_entity_available_entity_types', array());
+    if (empty($entity_types['file'])) {
+      return;
+    }
+  }
+

changed from !empty to empty

one patch should do, why more? I haven't tested this though, requires clean pathauto no patches

ron_s’s picture

I think there is a misunderstanding about the possible options.

The patch you suggested assumes Pathauto Entity takes over if the Pathauto Entity "File" checkbox is selected. However, that's not the core problem.

In our configuration, we have never enabled the "File" checkbox in Pathauto Entity settings. We assumed File Entity would be the way aliases are created.

The issue is that the pathauto_entity_update_alias function only checks if the entity is supported. So regardless of whether or not "File" is chosen, Pathauto Entity creates aliases for files when triggered, because it is always identified as a supported entity type. This creates a weird hybrid where Pathauto Entity is using File Entity's pathauto settings to create aliases.

If you want to terminate File Entity processing if Pathauto Entity exists (without a check for the checkbox setting), that could be one way to do it. However this would also require the File Entity textfields to be removed from pathauto.

By creating two separate patches, the goal was to allow the developer to decide which module controls file aliases. But maybe you want to give control to Pathauto Entity if it exists, since all entities can have aliases in D8? I haven't looked at the D8 version of File Entity. Is pathauto-related functionality removed?

ron_s’s picture

And just to be clear, the patch you're suggesting in #8 won't work.

Also from your comment in #7, if only the file_entity patch is applied, it allows Pathauto Entity to take control of the file alias creation. The other patch allows File Entity to have control over Pathauto Entity for files aliases.

The patches are trying to be agnostic to the approach a developer wants to take. If you always want to give up control to Pathauto Entity, that's fine, it could be done that way, but a different patch is necessary.

ron_s’s picture

One additional comment... why would you change !empty to empty? It has to be !empty.

The patch checks to see if the "File" checkbox is enabled in the Pathauto Entity settings. If not, it should continue processing with File Entity.

ron_s’s picture

So the only way this can be self-contained in File Entity is to essentially hand over control of pathauto settings to Pathauto Entity.

Here is a patch that does that. This does not require the Pathauto Entity patch I created, and the developer is responsible for understanding that the "File" checkbox in the Pathauto Entity settings must be selected for custom aliases to be created.

joseph.olstad’s picture

Hi ron_s, thanks for your hard work on this, I am thinking your latest patch #12 is the best solution, what do you think?

ron_s’s picture

It's certainly the most simple. I'm fine with it.

joseph.olstad’s picture

Status: Needs review » Reviewed & tested by the community

patch #12

any co-maintainer volunteers? I'm very busy lately.

joseph.olstad’s picture

I just triggered more tests

  • joseph.olstad committed cfe128f on 7.x-2.x authored by ron_s
    Issue #2206421 by ron_s: Conflict between File Entity and Pathauto...

  • joseph.olstad committed 65dff9e on 7.x-3.x authored by ron_s
    Issue #2206421 by ron_s: Conflict between File Entity and Pathauto...
joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

  • joseph.olstad committed 669520c on 7.x-3.x authored by ron_s
    Issue #2206421 by ron_s: Conflict between File Entity and Pathauto...

  • joseph.olstad committed 481f479 on 7.x-2.x authored by ron_s
    Issue #2206421 by ron_s: Conflict between File Entity and Pathauto...

Status: Fixed » Closed (fixed)

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