Problem/Motivation

Proposed resolution

Remaining tasks

User interface changes

API changes

Original report by @catch

If you want to change the path alias for a user, you have to first find the user and their uid then go into the path admin interface, find the alias, then edit it. This takes ages.

We should add a path alias form to the user edit screen if path module is enabled - same as is currently done for nodes.

CommentFileSizeAuthor
#127 interdiff_121-127.txt1.32 KBnarendra.rajwar27
#127 476294-127.patch3.58 KBnarendra.rajwar27
#124 afterPatch(2).JPG48.02 KBpankaj.singh
#124 afterPatch(1).JPG76.04 KBpankaj.singh
#124 beforePatch(2).JPG63.1 KBpankaj.singh
#124 beforePatch(1).JPG39.09 KBpankaj.singh
#123 path_alias_in_url.png34.84 KBnarendra.rajwar27
#123 path_alias_after_patch.png91.8 KBnarendra.rajwar27
#123 path_alias_before_patch.png77.91 KBnarendra.rajwar27
#121 interdiff_118_121.txt2.6 KBsharma.amitt16
#121 476294-121.patch3.59 KBsharma.amitt16
#118 476294-118.patch2.8 KBsharma.amitt16
#110 476294-110.patch3.9 KBrajeshwari10
#107 path_alias_user-476294-107.patch3.41 KBpk188
#102 Add-path-alias-to-user-edit-is-working.png73.71 KBcriscom
#102 Add-path-alias-to-user-edit-url-path-settings.png72.46 KBcriscom
#101 path_alias_user-476294-101.patch6.99 KBmarabak
#98 path_alias_user-476294-98.patch3.43 KBieguskiza
#96 path_alias_user-476294-96.patch2.43 KBieguskiza
#88 path_alias_user-476294-88.patch2.46 KBDom.
#85 path_alias_user-476294-85.patch2.46 KBDom.
#79 path_alias_user-476294-79.patch2.43 KBadci_contributor
#77 476294_77.patch2.43 KBravi.khetri
#69 476294_67.patch2.77 KBestoyausente
#66 476294_66.patch2.62 KBestoyausente
#63 476294_63.patch2.59 KBcosmicdreams
#59 drupal-path_alias_user-476294-59.patch2.3 KBer.pushpinderrana
#55 drupal-path_alias_user-476294-55.patch2.38 KBamitgoyal
#52 drupal-path_alias_user-476294-52.patch2.35 KBrealityloop
#46 drupal-path_alias_user-476294-46.patch2.35 KBsanchiz
#40 drupal-path_alias_user-476294-40.patch2.34 KBsanchiz
#27 476294_user_path-24.patch5.12 KBarianek
#24 476294_user_path-24.patch5.12 KBstBorchert
#21 476294_user_path-21.patch4.9 KBstBorchert
#18 476294_user_path-18.patch3.66 KBstBorchert
#14 476294_user_path-14.patch3.1 KBburningdog
#12 url_path_scrnsht.jpg11.53 KBpsicomante
#9 476294_user_path-9.patch3.29 KBpsicomante
#8 476294_user_path-8.patch3.48 KBstBorchert
#6 476294_user_path-6.patch3.45 KBstBorchert
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

Issue tags: +Usability
elvis2’s picture

Hey catch, I would like to tackle this. I am wondering, should the patch live in path or user module? Or a module of it's own?

And, merlinofchaos mentioned "toolbox" here: http://drupal.org/node/475968#comment-1641244

Is there already a helper module in place that deals solely with paths and url aliases?

catch’s picture

I'm not aware of one (although that doesn't mean it doesn't exist). One thing which would be similar to merlinofchaos' idea would be a menu link which lets you edit aliases for the current page - ideally we'd have a path like admin/settings/path/node/1 to point to but that doesn't exist.

tylor’s picture

I was looking at this one too as it's very similar to #476290: Add path alias to taxonomy term edit. It seems to me you should be able to achieve this just with path.module by using hook_user() and hook_form_alter() in a similar manner as is currently done with nodes. This is the approach I took to implement this for taxonomy.module (patch here: http://drupal.org/node/476290#comment-1853636).

Anyway, glad for the discussion and curious what the best approach will be.

elvis2’s picture

yes catch, do you have a recommendation on where this extra code should reside? I am wondering if there is some type of policy or coding standards when dealing with core. Do we add code to path.module or to user.module - to handle this issue?

stBorchert’s picture

Component: taxonomy.module » user system
Status: Active » Needs review
FileSize
3.45 KB

Here we go.

Status: Needs review » Needs work

The last submitted patch failed testing.

stBorchert’s picture

Status: Needs work » Needs review
FileSize
3.48 KB

Next try.

psicomante’s picture

FileSize
3.29 KB

cleaned form api (textfield doesn't support collaps[ed|ible]

tested and reviewed (code and functionality)

psicomante’s picture

Are you sure that put these functions on path.module is the correct way?

Bojhan’s picture

Needs screenshot.

psicomante’s picture

FileSize
11.53 KB

i hope this screenshot is that you're lookin' for :P

stBorchert’s picture

@Psicomante: Yes it needs to be in path.module because otherwise you'll have to check in user.module if the module "path" is installed. It would work but its cleaner to inject the path settings via form_alter in path.module.

burningdog’s picture

FileSize
3.1 KB

I tested the patch from #9 and it looks good. I was able to add a url alias when editing a user (which worked), visit the url, remove the url, add it directly as a url alias in admin/settings/path and edit it again, and also remove it - that all worked fine :)

There were a few minor formatting issues with the comments - I've re-rolled with those fixed (thank you, coder module!).

chachasikes’s picture

Assigned: Unassigned » chachasikes

trying this issue out as my first patch review

chachasikes’s picture

Status: Needs review » Needs work

Hi catch!

I reviewed this patch (and this is my first review, btw)

The patch itself works. I was also able to apply the patch and then add an alias to user accounts. Visiting the alias also worked.

(I'm still figuring out how to make patches from my drupal install -- so I'm just pasting some code for you here.)

However, a few things are necessary for this patch, mostly comments.

1. Here is the beginning of a comments for the new function: _path_user_form_inject_path(&$form)

/**
* Add path settings to user register form.
*
* Returns fieldset with URL path settings.
* This allows a URL alias to specify an alternative URL by which the user's profile can be accessed.
*/
function _path_user_form_inject_path(&$form) {

2. This function could use more comments (what form elements you are adding and why) However, no one else in Drupal 7 has done this for any form altering functions. That seems kind of a bad practice, especially when there are dozens of form_alter calls and they all do different things. So, while I am not recommending that you add any more comments for this...I would personally like to find out why this is a common practice in Drupal.

path_form_user_profile_form_alter(&$form, &$form_alter) {

3. This function could use some documentation for the arguments (though this one is probably also a drupal-wide problem.) I ask because it is not immediately apparent what the &$edit variable is, or what the $category is....:

function path_user_submit(&$edit, &$account, $category = NULL) {

4. Is 'inject' the best word for a function name? (I'm not sure) There were not any other functions in d7 with that word in it. I did find the word 'inject' in the code, but it was in the doc-block for the function. Maybe you could change the function name from _path_user_form_inject_path _path_user_form_path ?

Here is a similar example:
/**
* Inject links into $node for attachments.
*/
function upload_node_links($node, $build_mode) {
$links = array();

Other things I thought about, but decided it was OK the way you did it (at least from my perspective)

a. setting access permissions to user 'create URL alias' - This makes sense because only users who can edit users can adjust the user alias. This is totally different than, say, adding taxonomy terms for users & classifying them.

b. not setting the default alias to 'user/useralias' -- i think it makes sense to create ANY alias you want - and that can be configured with pathauto

Other things to test
This module should be tested with pathauto, that pathauto filters will work with users.

chachasikes’s picture

Assigned: chachasikes » Unassigned

unassigning this issue

stBorchert’s picture

Status: Needs work » Needs review
FileSize
3.66 KB

@chachasikes
Thanks for your review.

@1.: Added comment to function.

@2.: Added some comment.
Why it (and what exactly) is "bad practice"? Using a helper function to add the form elements rather than inserting duplicate code?
Or do you mean the use of hook_form_FORM_ID_alter?

@3.: http://api.drupal.org/api/function/hook_user/7
hook_user_submit doesn't have its own document page, yet.

@4.: I've chosen "inject" because thats what it does. It injects some elements into an existing form. But I'm not nailed down to this wording ...

Shawn DeArmond’s picture

Status: Needs review » Reviewed & tested by the community

Patch works as advertised. Good idea!

cwgordon7’s picture

Status: Reviewed & tested by the community » Needs work
+++ modules/path/path.module	9 Aug 2009 10:17:21 -0000
@@ -250,6 +250,110 @@ function path_form_alter(&$form, $form_s
+    // If we already have a path add its id so we can update the path rather than creating
+    // a new one after saving the profile.

Comments should wrap at 80 characters.

+++ modules/path/path.module	9 Aug 2009 10:17:21 -0000
@@ -250,6 +250,110 @@ function path_form_alter(&$form, $form_s
+  // Add custom submit handler to the user register form because there is no hook.

Comments should wrap at 80 characters.

+++ modules/path/path.module	9 Aug 2009 10:17:21 -0000
@@ -250,6 +250,110 @@ function path_form_alter(&$form, $form_s
+/**
+ * Custom submit handler for the user registration form to save an optional url alias.
+ */

Comments should wrap at 80 characters.

+++ modules/path/path.module	9 Aug 2009 10:17:21 -0000
@@ -250,6 +250,110 @@ function path_form_alter(&$form, $form_s
+  path_set_alias('user/' . $account->uid, isset($edit['path']) ? $edit['path'] : NULL, isset($edit['pid']) ? $edit['pid'] : NULL);

Can we expand this logic into multiple lines for increased code readability?

Other than that, looks pretty good.

stBorchert’s picture

Status: Needs work » Needs review
FileSize
4.9 KB

New patch with updated comments.

Status: Needs review » Needs work

The last submitted patch failed testing.

stBorchert’s picture

Argh, this is because I can only use diff instead of cvs diff here. Will reroll later today.

stBorchert’s picture

Status: Needs work » Needs review
FileSize
5.12 KB

Updated the patch (again).

Status: Needs review » Needs work

The last submitted patch failed testing.

stBorchert’s picture

Status: Needs work » Needs review

Dear bot: please retest.

arianek’s picture

FileSize
5.12 KB

patch applied cleanly to head - reuploading for test bot

Bojhan’s picture

Status: Needs review » Reviewed & tested by the community

All cwgordons issues have been adressed, back to RTBC?

sun’s picture

Status: Reviewed & tested by the community » Needs work

I don't agree with the approach taken here. Instead of introducing new functions that almost match the existing functions, the existing functions should be extended to work for more entities/object types.

webchick’s picture

Additionally, could I get clarification on the use case here?

Taxonomy terms I get. It's very conceivable that you have a free-tagging vocab where you don't really care what the URLs are, but in your "Product Type" vocabulary, you specifically want URLs like example.com/tshirts, example.com/videos, etc.

But users? Is there a use case for user/1, user/2, user/3, user/tom_the_frightening_toast?

Seems like this is a classic case where you'd want a pattern-based URL-generator like Pathauto, not a one-off thing, which would result in terribly inconsistent user profile URLs.

sun’s picture

@webchick: A form widget to enter any URL alias for a user is a pre-condition for auto-generated aliases. You always need a way to override those.

sun’s picture

Issue tags: +API clean-up

Introducing a new tag for feature freeze: API clean-up.

sbefort’s picture

Subscribing.

webchick’s picture

Version: 7.x-dev » 8.x-dev
Category: task » feature
Dave Reid’s picture

I think we'll likely accept a patch in Pathauto for D7 to add this to the user forms.

cosmicdreams’s picture

Given the new approach proposed in #29, is this still a Novice issue?

andypost’s picture

andriyun’s picture

Issue tags: +dcdn-sprint
andriyun’s picture

Assigned: Unassigned » andriyun
sanchiz’s picture

There is patch which works with another patch from parent issue https://drupal.org/node/2201051#comment-8722973

sanchiz’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 40: drupal-path_alias_user-476294-40.patch, failed testing.

sanchiz’s picture

Status: Needs work » Postponed
sanchiz’s picture

Assigned: andriyun » sanchiz
sanchiz’s picture

Status: Postponed » Needs work

Continue work.

sanchiz’s picture

sanchiz’s picture

Status: Needs work » Needs review
tmbritton’s picture

Issue summary: View changes

I tested patch, seems to work correctly.

sanchiz’s picture

Still no updates?

realityloop’s picture

Berdir’s picture

I'm not sure sure this makes too much sense unless you use it in combination with pathauto and then possibly only for administrative users? You wouldn't want to give your users full control over the alias they can use? The only thing you might want to is have a field where they can for example control /user/[something], then you'd in turn use pathauto to generate the actual path.

What I have in mind is a feature for pathauto in 8.x that allows to simply check of which entity types should have this field, which at the same time would also enable them to have pathauto alias patterns.

a_thakur’s picture

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

The patch does not apply to latest drupal 8(branch 8.0.x) code base.

amitgoyal’s picture

garphy’s picture

Status: Needs work » Needs review
sanchiz’s picture

Assigned: sanchiz » Unassigned
Jalandhar’s picture

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

The patch does not apply to latest drupal 8(branch 8.0.x) code base.

er.pushpinderrana’s picture

Status: Needs work » Needs review
FileSize
2.3 KB

Reolled #55 patch.

Status: Needs review » Needs work

The last submitted patch, 59: drupal-path_alias_user-476294-59.patch, failed testing.

andriyun’s picture

er.pushpinderrana
Your patch is missing closing curly brace in 113 line
/core/modules/path/path.module

+++ b/core/modules/path/path.module
@@ -58,28 +58,25 @@ function path_permission() {
@@ -93,3 +90,23 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) {

@@ -93,3 +90,23 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) {
     return $fields;
   }
 }
+
+/**
+ * Returns form element for path settings.
+ */
+function path_settings_form_element(&$form) {
+  $form['path_settings'] = array(
+    '#type' => 'details',
+    '#title' => t('URL path settings'),
+    '#open' => !empty($form['path']['widget'][0]['alias']['#value']),
+    '#group' => 'advanced',
+    '#attributes' => array(
+      'class' => array('path-form'),
+    ),
+    '#attached' => array(
+      'library' => array('path/drupal.path'),
+    ),
+    '#weight' => 30,
+  );
+  $form['path']['#group'] = 'path_settings';
+
 

There should be closing brace

andypost’s picture

sure, still need re-roll

cosmicdreams’s picture

Status: Needs work » Needs review
FileSize
2.59 KB

rerolled.

Status: Needs review » Needs work

The last submitted patch, 63: 476294_63.patch, failed testing.

andypost’s picture

+++ b/core/modules/path/path.module
@@ -58,28 +56,25 @@ function path_permission() {
+function path_form_user_form_alter(&$form, $form_state) {
+  $user = $form_state['controller']->getEntity();

form state should be a class #2335659: Remove FormState ArrayAccess usage from core

estoyausente’s picture

FileSize
2.62 KB

I have changed it. It seems that run ok.

estoyausente’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 66: 476294_66.patch, failed testing.

estoyausente’s picture

Issue tags: +Amsterdam2014
FileSize
2.77 KB

Now it pass this test in my local.

estoyausente’s picture

Status: Needs work » Needs review

realityloop queued 69: 476294_67.patch for re-testing.

star-szr’s picture

Status: Needs review » Needs work

Looks like this needs another reroll.

However it's worth pointing out that this is currently filed as a 'Feature request' so it's more likely that this would be added to 8.1.x than 8.0.x.

estoyausente’s picture

Yes, really I think that is better wait for a more stable 8.0.x for do the rerolling. Ty for all Cottser. :)

rpayanm’s picture

Version: 8.0.x-dev » 8.1.x-dev

Status: Needs work » Needs review

estoyausente queued 69: 476294_67.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 69: 476294_67.patch, failed testing.

ravi.khetri’s picture

Status: Needs work » Needs review
FileSize
2.43 KB

Rerolled.

Status: Needs review » Needs work

The last submitted patch, 77: 476294_77.patch, failed testing.

adci_contributor’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
2.43 KB

I'm just fixed an endline and cleaned a whitespace in #77.

Status: Needs review » Needs work

The last submitted patch, 79: path_alias_user-476294-79.patch, failed testing.

balsama’s picture

Assigned: Unassigned » balsama
balsama’s picture

Issue tags: +SprintWeekend2015
balsama’s picture

Status: Needs work » Needs review

path_alias_user-476294-79.patch queued for retesting.

balsama’s picture

Assigned: balsama » Unassigned
Dom.’s picture

Just changed patch from @adci_contributor #79 to make it applying current HEAD.
Also tested it: it works, but I let someone else RTBC ! ^^

Status: Needs review » Needs work

The last submitted patch, 85: path_alias_user-476294-85.patch, failed testing.

Dom.’s picture

Version: 8.1.x-dev » 8.0.x-dev
Status: Needs work » Needs review

Oups!
Just re-rolling patch under 8.0.x-dev !! (héhé)

Dom.’s picture

andypost’s picture

The path_settings_form_element() is not actually reusable because assumes $form['path'] so maybe better to implement that function with argument of path field?

Also usage of this details could be configured on path field widget...

+++ b/core/modules/path/path.module
@@ -43,28 +43,24 @@ function path_help($route_name, RouteMatchInterface $route_match) {
 function path_form_node_form_alter(&$form, FormStateInterface $form_state) {
...
+  path_settings_form_element($form);
...
+function path_form_user_form_alter(&$form, $form_state) {
...
+    path_settings_form_element($form);
...
-  if ($entity_type->id() === 'taxonomy_term' || $entity_type->id() === 'node') {
+  if ($entity_type->id() === 'taxonomy_term' || $entity_type->id() === 'node' || $entity_type->id() === 'user') {

@@ -80,6 +76,26 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) {
+function path_settings_form_element(&$form) {
+  $form['path_settings'] = array(
+    '#type' => 'details',

A bit confusing to have details on user and node forms but no on taxonomy term

Status: Needs review » Needs work

The last submitted patch, 88: path_alias_user-476294-88.patch, failed testing.

dcmul’s picture

But do we really need details on user form? and not on taxonomy form?
Why don't we implement path in user the same way it was done for taxonomy, with no details.

And on approach

+    '#group' => 'advanced',

that line seems redundant, since there is no advanced group in user form unlike node form.

dawehner’s picture

Thank you for the work on that.

Why do we consider doing a feature request for 8.0, that certainly sounds like 8.1 material for me.

lauriii’s picture

Version: 8.0.x-dev » 8.1.x-dev

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ieguskiza’s picture

Assigned: Unassigned » ieguskiza
Status: Needs work » Needs review
Issue tags: +Dublin2016
FileSize
2.43 KB

Hi,
I'm submitting a tentative patch to harmonize the behavior of the path field inside entities.
As noted in previous comments it makes no sense for the path field to be inside details on the node form but not on taxonomy or user ones so I harmonized it and added it inside details in all forms.

Part of the Drupalcon Dublin 2016 sprints.

Status: Needs review » Needs work

The last submitted patch, 96: path_alias_user-476294-96.patch, failed testing.

ieguskiza’s picture

Status: Needs work » Needs review
FileSize
3.43 KB

Resubmitting the previous patch in order to pass tests.

ieguskiza’s picture

Assigned: ieguskiza » Unassigned
criscom’s picture

I will review the patch by ieguskiza in #98 on Drupalcon Dublin.

marabak’s picture

the patch is not applying
i re-rolled it

criscom’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
72.46 KB
73.71 KB

The patch applied cleanly for me.
Downloaded and enabled pathauto, token and ctools.
Set a url path for my user.
Working perfectly.

apply url

working

Berdir’s picture

This patch is not needed for pathauto to work, as it has settings that allow to enable the field on every entity type.

I do not think having this makes sense without automatically generated aliases, so I'm kind of -1 on adding this to core.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 101: path_alias_user-476294-101.patch, failed testing.

ieguskiza’s picture

The same could be said for taxonomy terms but I guess it was decided to add them directly through the path module because of the widespread usage we give to aliases in regards to these entities.

That being said, I agree that assuming the same usage for user entities is quite far-fetched and probably a very specific case for certain sites. Also the path field was never added for users in the core of Drupal 7 to begin with, so even though I provided a patch for this feature I will also say that we would be better of scrapping it.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pk188’s picture

Status: Needs work » Needs review
FileSize
3.41 KB

Re rolled #98 as not applied.

Status: Needs review » Needs work

The last submitted patch, 107: path_alias_user-476294-107.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

rajeshwari10’s picture

Assigned: Unassigned » rajeshwari10
rajeshwari10’s picture

Assigned: rajeshwari10 » Unassigned
Status: Needs work » Needs review
FileSize
3.9 KB

I have done changes in "core.entity_form_display.user.user.default.yml" as the error was coming from file.

Please Review

Thanks!!

Status: Needs review » Needs work

The last submitted patch, 110: 476294-110.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

sharma.amitt16’s picture

Status: Needs work » Needs review
FileSize
2.8 KB

The patch is not applying on the D9.1.x branch.

Re-rolling the patch for the same.

Status: Needs review » Needs work

The last submitted patch, 118: 476294-118.patch, failed testing. View results

sharma.amitt16’s picture

Assigned: Unassigned » sharma.amitt16
sharma.amitt16’s picture

Status: Needs work » Needs review
FileSize
3.59 KB
2.6 KB

Below is the output of test cases that are passed on local which are failed in the previous patch.

root@b1dad303faf2:/var/www/html# phpunit --configuration=core --filter testMediaForm core/modules/path/tests/src/Functional/PathMediaFormTest.php
PHPUnit 8.5.4 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\path\Functional\PathMediaFormTest
.                                                                   1 / 1 (100%)

Time: 5.75 minutes, Memory: 8.00 MB

OK (1 test, 10 assertions)

HTML output was generated



root@b1dad303faf2:/var/www/html# phpunit --configuration=core --filter testConfig core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
PHPUnit 8.5.4 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest
.                                                                   1 / 1 (100%)

Time: 24.97 minutes, Memory: 8.00 MB

OK (1 test, 215 assertions)
sharma.amitt16’s picture

Assigned: sharma.amitt16 » Unassigned
narendra.rajwar27’s picture

@sharma.amitt16, I have tested by applying this patch, and the path alias functionality working fine.



pankaj.singh’s picture

Tested the patch given in #121. Patch applied successfully and changes are reflecting with custom path aliasing.

Please refer to SS for ref. RTBC+1

PapaGrande’s picture

Status: Needs review » Needs work
+++ b/core/modules/path/path.module
@@ -98,7 +99,9 @@ function path_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity
+  $default_entity_types = ['taxonomy_term', 'node', 'media', 'user'];

Small nit, but since you are defining $default_entity_types twice in the module, I wonder if it makes sense to create a constant or helper function to get the array values. Then it can be well documented, and if a new entity type is added, it only has to added in one place.

Otherwise, the code looks good.

narendra.rajwar27’s picture

Working on it.

narendra.rajwar27’s picture

Status: Needs work » Needs review
FileSize
3.58 KB
1.32 KB

@PapaGrande, Thank you for review. Updating the patch as comment #125

Status: Needs review » Needs work

The last submitted patch, 127: 476294-127.patch, failed testing. View results

narendra.rajwar27’s picture

Status: Needs work » Needs review

Test case failed due to random failure, adding test again passed. changing issue status.

PapaGrande’s picture

Status: Needs review » Reviewed & tested by the community

Successfully tested by a few people and the code looks good to me. Well done!

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/path/path.module
@@ -156,3 +164,29 @@ function path_field_widget_form_alter(&$element, FormStateInterface $form_state,
+
+/**
+ * Implements hook_form_alter().
+ */
+function path_form_alter(&$form, FormStateInterface $form_state) {
+  if ($form_state->getFormObject() instanceof EntityFormInterface) {
+    $entity = $form_state->getFormObject()->getEntity();
+    if (in_array($entity->getEntityTypeId(), DEFAULT_ENTITY_TYPES)) {
+      $form['path_settings'] = [
+        '#type' => 'details',
+        '#title' => t('URL path settings'),
+        '#open' => !empty($form['path']['widget'][0]['alias']['#value']),
+        '#group' => 'advanced',
+        '#access' => !empty($form['path']['#access']) && $entity->hasField('path') && $entity->get('path')->access('edit'),
+        '#attributes' => [
+          'class' => ['path-form'],
+        ],
+        '#attached' => [
+          'library' => ['path/drupal.path'],
+        ],
+        '#weight' => 30,
+      ];
+      $form['path']['#group'] = 'path_settings';
+    }
+  }
+}

With the base field definmition, path_form_alter() shouldn't be necessary here - we already show the field on the node form without this alter being in place. If it is necessary, then something seems wrong.

Berdir’s picture

That logic was moved to Drupal\path\Plugin\Field\FieldWidget\PathWidget::formElement(), dynamically based on the advanced key.

This is based on very old patches and was rerolled incorrectly from that as that part has been removed.

That said, I'm still not fully convinced about doing this by default. I think aliases for user profiles is a _very_ rare use case, especially creating them manually. What is the use case for that when you don't use pathauto? And if you do, it's just a checkbox to enable it for user (like any other entity type as well).

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Is this a duplicate of #1057570: Create user/edit menu path to edit the current user's account? They sound very similar but have completely different solutions.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.