Just updated Drupal from 8.4.2 to 8.4.3.

After this update it seems it takes two times before PathAuto works after new content is being saved. Creating new content, with a Pathauto pattern assigned to it, and pressing the Save button after that, does not trigger the Pathauto automatically anymore. Going right back into the edit mode of that content, pressing the Save button, DOES trigger PathAuto. In other words, you have to save new content 2 times before Pathauto gives the correct pattern.

If there are blocks assigned to that specific PathAuto pattern, it also does not show these blocks after saving the new content for the first time. (because of the /node/xxxx url)

And all this started after updating Drupal to 8.4.3.
I can live with 2 times Saving new content.......I can imagine other can't.

Any ideas?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

XS2ICE created an issue. See original summary.

oltus’s picture

Same here. Path auto is not working even on bulk update admin/config/search/path/update_bulk...

XS2ICE’s picture

Actually, it does work, but not immediately after the first time of saving new content......

drupgirl’s picture

You have to use the correct replacement patterns, e.g., help/[node:title]. Be sure to leave off the leading / that D8 requires for links.

XS2ICE’s picture

drupgirl Credit
Attribution: drupgirl
commented 2 days ago
You have to use the correct replacement patterns, e.g., help/[node:title]. Be sure to leave off the leading / that D8 requires for links.

Thanks, but the patterns I use are correct. Otherwise, it would also fail the 2nd time saving new content.

But thanks for the reminder.

Berdir’s picture

Status: Active » Postponed (maintainer needs more info)

What is your pattern configuration? Some tokens might only work on existing entities.

XS2ICE’s picture

FileSize
391.06 KB

I added a printscreen.

Drupal Pathauto Pattern.jpg

Is this helpfull ?

KlemenDEV’s picture

I can confirm I have the same issue. The alias is not created on the content creation, but when the content is edited. This is a very problematic on our website, as we have user contributed content and a lot of aliases are not generated due to this bug.

Berdir’s picture

Usually that means you are relying on a path alias that only works on a a saved entity because it needs to load something that it can't on a new, not yet saved entity.

So you need to at least share your pattern configuration so that I can try to help.

KlemenDEV’s picture

This is the pattern I use: /page/[node:nid]/[node:title]

Berdir’s picture

Yes, that can't work. The nid only exists after saving. It should create that as just page/title

KlemenDEV’s picture

I think this needs to be improved. Many pages use this format or a similar one which includes [node:title] for the SEO reasons and for readability. This is probably the most common use case of this module.

If the page is a large website with many user contributions, this can be quite a problem. If I recall properly, this worked in Drupal 7 as our website used to be on this platform and we used the same pattern and it worked.

Is there no option to either get title data from the form or generate the alias after the node is stored (hook_node_insert)?

Georgii’s picture

@Klemen Pevec

My impression that the response #11 was about [node:nid] not [node:title]. Or are you saying you have the issue with only the [node:title] token in your pattern?

Thib’s picture

I've same issue with this kind of pattern projets/[node:title]

Georgii’s picture

@Thib,
In your case what actions caused an issue? New node creation? Editing a content with title modification? Can you reproduce it at 100% or attempts? Please give some more details.

Maybe I can reproduce it and look into the details.

Ruslan Piskarov’s picture

Status: Postponed (maintainer needs more info) » Active
FileSize
486 bytes

Hello.

Maybe I can help by providing some info.

Checked Drupal core 8.4.3 and 8.4.4.
Pathauto 8.x-1.0.

Whan I am trying to create or edit any node I am getting the fatal error.

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\pathauto\PathautoItem::ensureLoaded() in Drupal\path\Plugin\Field\FieldType\PathItem->setValue() (line 69 of core/modules/path/src/Plugin/Field/FieldType/PathItem.php).
Drupal\path\Plugin\Field\FieldType\PathItem->setValue(Array, ) (Line: 201)
Drupal\Core\TypedData\TypedDataManager->getPropertyInstance(Object, 0, Array) (Line: 82)
Drupal\Core\Field\FieldTypePluginManager->createFieldItem(Object, 0, Array) (Line: 41)
Drupal\Core\Field\FieldItemList->createItem(0, Array) (Line: 41)
Drupal\path\Plugin\Field\FieldType\PathFieldItemList->computeValue() (Line: 38)
Drupal\path\Plugin\Field\FieldType\PathFieldItemList->ensureComputedValue() (Line: 142)
Drupal\path\Plugin\Field\FieldType\PathFieldItemList->count()
count(Object) (Line: 67)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 168)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 122)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 113)
Drupal\node\NodeForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('node_page_edit_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('node_page_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Ruslan Piskarov’s picture

Also on /admin/config/search/path/settings
I see the following:

Warning: in_array() expects parameter 2 to be array, null given in Drupal\pathauto\Form\PathautoSettingsForm->buildForm() (line 101 of modules\contrib\pathauto\src\Form\PathautoSettingsForm.php).
Drupal\pathauto\Form\PathautoSettingsForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('pathauto_settings_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('pathauto_settings_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

It's very strange, because I use this module for few sites and Pathauto works perfect for each, except of one. Will investigate.

Berdir’s picture

Sounds like enabled_entity_types is not an array, but I don't think those two things have anythin in common.

Ruslan Piskarov’s picture

Status: Active » Postponed (maintainer needs more info)

Ah sorry.
After uninstalling Pathauto I got another error:
The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\path\Plugin\Field\FieldType\PathItem::ensureLoaded() in Drupal\path\Plugin\Field\FieldType\PathItem->setValue() (line 69 of core\modules\path\src\Plugin\Field\FieldType\PathItem.php).

So this error not related to Pathauto and you can ignore my comments.

XS2ICE’s picture

@Berdir, did the printscreen at #7 give any information?

For your information, I don't recieve any error messages.

KlemenDEV’s picture

I have found out that /page/[node:nid]/[node:title] works in most cases even when the content is just created.

But it does not work if the node has a file field with files attached to it. In such case, the alias is created on the node edit rather on the creation.

hallogallo’s picture

But it does not work if the node has a file field with files attached to it. In such case, the alias is created on the node edit rather on the creation.

Second this. Same issue on both live and local test installation.

Add: Also we don:t use [node:nid] but creationdate/node-title, but same issue with no alias saved upon first save of node, but saved when editing and saving once again.

KlemenDEV’s picture

Maybe a separate issue should be opened for the case of the file field? I think this is an issue with a priority that should be higher than normal.

Thib’s picture

@Georgii It's happened, as it said in the others comments, after new node creation.
Editing content solve the problem...

dandaman’s picture

I've had this happen on content where the "URL Alias" field (to set the path) is disabled on the creation form. It seems that if it's enabled on the creation form, the pathauto URL is set. But if it's not present, it does not work. For some sites, I just enabled the "URL Alias" field. Oddly, even if on the edit form it's disabled, it works there.

Is that what others are seeing? Is your "URL Alias" field hidden on the content types you were having issues with?

Berdir’s picture

There were various reports since 8.4 about strange effects. Only found time now to start looking into it. Can you check if #2945734: Fix automated test failures in 8.x-1.x is fixing this for you?

If not, a failing test would be helpful.

XS2ICE’s picture

#25 works for me. URL Alias was not activated. After activating, the URL alias was created after saving a new node.

Thanks a lot, this saves a huge amount of time for me.

#26: My knowledge does not reach this far to execute a (failing) test. Since #25 is the perfect solution for me, I rest my case.

Berdir’s picture

@XS2ICE

The issue title is not relevant. The tests are broken because of bugs and my changes should fix a lot of the reported problems.

That said, if you do want to have the URL Alias field visible then is fine. I'm interested in others who want it to be hidden to provide feedback there.

KlemenDEV’s picture

Is anyone working on solving this issue? I am talking about the issue described in the issue post, not all other issues posted in comments. One of 100% working cases to replicate this issue is described in my comment #21.

If there is no current workaround, at least a feature to rebuild failed aliases (bulk generate) on the cron run would be some form of working workaround.

adrienco88’s picture

I had a similar issue, with the PathAuto, just for me was happening every time I saved an article (new or edit).
My error was:
Warning: preg_match(): Compilation failed: nothing to repeat at offset 47 in Drupal\pathauto\AliasCleaner->cleanTokenValues() (line 342 of modules/contrib/pathauto/src/AliasCleaner.php).

After some debugging, I found out that I have ?=s safe token under admin/config/search/path/settings.
The solution was to escape the token since it was passed to "preg_match()" so I changed it in \?s\= and the error was gone.

Maybe this helps somebody.

Best Regards,
Adrian

amateescu’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

The problem reported in #21 / #25 is being fixed in #2946273: Alias is not generated when Pathauto widget is hidden.

Deno’s picture

I have experienced exactly the same error with group/add, on Drupal 8.7.6. A bit more details:

- I have two group types (let's call them "A" and "F"), for one (A) adding of pathalias on group/add works, for the other (F) it fails but it works on update.
- Making the url alias widget visible in the "F" group/add form indeed makes it work for "F" again. (This is a workaround, but not a solution.)
- There are no error messages in the log.

I have tried the following to see if anything changes with negative results:

- Remove the "file" field that we aren't using from the "F" data model.
- Add all fields *except* for the url alias to the group/add form mode of the group F
- Removing the url alias widget from the default edit form of the group F (alias is still generated on update)
- Add group/add form for the group A type (aliasing still works on group/add)

Ah, we found one: we are using busines rules and dependent field. if the dependent field is shown in the group/add form, the alias is not made. if it isn't it works again.