Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Once #2655780: Allow to configure entity types to add path base fields (so that Pathauto can apply for them) is in, we'll no longer need a custom hook_base_field_info() implementation to add the path field.
Proposed resolution
Remove it, update the test to set the necessary configuration instead.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#25 | 2655844-24.patch | 3.18 KB | bharath-kondeti |
| |||
#22 | remove_file_entity_entity_base_field_info-2655844.patch | 3.18 KB | robcarr |
| |||
#8 | remove-2655844-8.patch | 1.72 KB | Berdir |
#3 | 14.patch | 2.13 KB | Berdir |
Issue fork file_entity-2655844
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Berdirhttps://github.com/drupal-media/file_entity/pull/14
Comment #3
BerdirI've merged the pathauto issue now and rebased the PR.
Note that this will not work yet on d.o testbot until pathauto has a new release. Uploading a patch as well to prove that.
Comment #8
BerdirComment #9
BerdirComment #12
rutiolmaUploading a new patch that applies to the latest version. This patch also adds a default configuration to enable path alias field on install/update
Comment #13
rutiolmaNow the patch...
Comment #15
rutiolmaFixing test
Comment #16
Berdirthis update is wrong and assumes that no other types are enabled. needs to get the existing values and add file.
There is also no need to do this for new installations IMHO.
I'd even consider going one step further and only enabling it if there is a pathauto pattern or file aliases and otherwise just display a message that it can be enabled in pathauto if desired.
Comment #17
rutiolmaIndeed there's an issue with the patch.
Before fixing it I would like to understand your pov @Berdir. By default, an URL alias field is added if pathauto exits, so I just tried to keep the same behavior. Do you mean that this behavior should change?
About your "step further" I believe you're referring to the hook_update, right?
Comment #18
BerdirYes, because a setting would be more complexity. But I think the use case for requiring url aliases on files are _very_ rare, usually you do not expose that publicly and therefore don't need aliases. So I'm proposing that we enable it only if there is a good reason to. If someone does need it after all, they can easily enable it themself. So we can return a message like 'Files no longer have an alias field by default, enable it in the pathauto settings if you wish to use that.'. Then a site either sees that message when updating (it now works like any other entity type provided by contributed modules) or if necessary, we keep the field.
And yes, that code only lives in the update function, no shared function required anymore, and no changes to hook_install().
Comment #19
rutiolmaAddressing @Berdir feedback
Comment #20
robcarrThe patch applies although when running the database update 8201, it generates the following errors:
Comment #21
robcarrIf
accessCheck(TRUE)
is inserted into the relevant query in the file_entity.install file, then the update runs fine:Comment #22
robcarrUpdated patch attached
Comment #23
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedYou'd actually want
->accessCheck(FALSE)
Because you don't want the access checking enabled for this query.
Comment #25
bharath-kondeti CreditAttribution: bharath-kondeti as a volunteer and at Specbee commentedUpdated the patch addressing #23. Please review
Comment #27
bharath-kondeti CreditAttribution: bharath-kondeti as a volunteer and at Specbee commentedComment #28
joseph.olstadReview so far:
I grepped all Drupal 8 projects using grep . xnddx . ru , currently only the file_entity is using this api function name .
It's likely a safe change to make above, thanks for your work.
@berdir, are you ok with this change?
Comment #29
joseph.olstadComment #30
c_archer CreditAttribution: c_archer as a volunteer and commentedTested patch on #25 and it worked as hoped.
Comment #32
joseph.olstadGitlab didn't use the commit message I specified, grumble.
Should have been this:
git commit -m 'Issue #2655844 by rutiolma, bharath-kondeti, Berdir, robcarr, joseph.olstad, Steven Jones, c_archer: Remove file_entity_entity_base_field_info()' --author="Sascha Grossenbacher <5019-berdir@users.noreply.drupalcode.org>"
Comment #33
joseph.olstadIncluded in rc2
Comment #34
webdrips CreditAttribution: webdrips commentedI'm not sure if it's best to start a new issue or use this one, but after upgrading to RC2 and running the database updates, I'm noticing the following:
This was the only update I applied, so I don't see how this error could've come from anywhere else.
I tried uninstalling this module and reinstalling it (after running Cron), and the same for pathauto, but I can't seem to get rid of this message.
Comment #35
paintingguy CreditAttribution: paintingguy commentedI have the same issue as @webdrips after updating to rc2
Comment #36
joseph.olstadreverting this, a new release to follow
Comment #39
joseph.olstadComment #40
joseph.olstadThanks for reporting the issues, it is reverted in rc4
https://www.drupal.org/project/file_entity/releases/8.x-2.0-rc4
Comment #41
webdrips CreditAttribution: webdrips commentedRC4 Removed the Status Report error message for me.
Comment #42
Steven Jones CreditAttribution: Steven Jones at ComputerMinds commentedRC4 added it back for me, this patch removed it.
@webdrips I wonder if you want a URL alias field on your files? Maybe we need to be smarter about when the base field is declared, are you also using the latest versions of pathauto?