Closed (duplicate)
Project:
Drupal core
Version:
main
Component:
file.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
24 Feb 2019 at 13:14 UTC
Updated:
14 May 2026 at 07:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
claudiu.cristeaPatch.
Comment #4
claudiu.cristeaFixing failures.
Comment #6
claudiu.cristeaWhat if a 3rd party module does
drupal_static_reset('file_get_file_references')? This call will never reset anything. With #4, this is a BC break. So, we need to properly deprecate the usage ofdrupal_static_reset('file_get_file_references'). And this needs a reset cache mechanism. Fixed in this patch. Note that the ::resetCache() method is public but not on the interface as the internal memory cache is just an implementation detail. Fixed also the CR.Added tests.
Comment #7
claudiu.cristeaConverted the test to a Kernel test as fits better. Covered also FileAccessControlHandler::getFileReferences().
Comment #10
hardik_patel_12 commentedRe-rolling against 9.1.x-dev.
Comment #12
nitesh624Comment #13
nitesh624Comment #14
hardik_patel_12 commentedComment #15
nitesh624remove unused use statement from
/core/modules/file/tests/src/Kernel/FileUsageDeprecationTest.phpComment #16
hardik_patel_12 commentedDrupal 9 was released, so we need to update the deprecation messages.
Comment #17
nitesh624Comment #18
nitesh624@Hardik_Patel_12 ok i will check
Comment #19
nitesh624Comment #21
nitesh624wrong patch added in #18 please ignore
Comment #22
nitesh624Comment #25
naresh_bavaskarComment #26
nitesh624Comment #27
nitesh624Comment #28
nitesh624Comment #29
cburschkalast two interdiffs, for completeness
Comment #30
cburschkaAre these intentional changes? They do not look in any way related to the patch. They were added in #21.
Edit: They seem to be partially reverting #2908079: Move some of the bootstrap.inc PHP-related constants to \Drupal and deprecate the old versions, indicating a botched re-roll. I'll fix it.
Comment #31
cburschkaFixing the bad reroll.
Comment #32
cburschkaAlso updating the deprecation messages from 8.8.0/9.0.0 to 9.1.0/10.0.0.
Comment #34
nitesh624Comment #35
nitesh624Comment #37
naresh_bavaskar@cburschka agreed on changes of
updating the deprecation messages from 8.8.0/9.0.0 to 9.1.0/10.0.0Just for consistency of
is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0tois deprecated in drupal:9.1.0 and is removed from drupal:10.0.0did and fixed test cases fail.Thanks! Please review
Comment #39
nitesh624Comment #40
nitesh624fix the test cases failure in #37
Comment #41
nitesh624Comment #44
tedbowNow in 9.3.x we need to remove all the instance of
@expectedDeprecation.Instead use
$this->expectDeprecation(DEPRECATION_MESSAGE_HERE)You can just copy the string from after
@expectedDeprecationIt looks like beside that the test should pass 🎉
Comment #45
meenakshi_j commentedComment #46
claudiu.cristeaThese changes are wrong. We need to move the assertion inside the function and remove the annotation. E.g.
Comment #47
claudiu.cristeaAlso messages should be changed to refer to drupal:9.3.0 and the messages pattern should follow #3024461: Adopt consistent deprecation format for core and contrib deprecation messages.
Comment #48
paulocsOn it.
Comment #50
paulocsI changed to MR approach to make the review easier.
I addressed #46 and #47.
Comment #51
claudiu.cristea@paulocs, now it's hard to understand the changes you made. So, the review is not easier. You should have apply changes from #45, then do a first commit in the MR. After do your changes and do a 2nd commit or, better, atomic commits for each specific remark. That would have been really useful to understand the changes. Could you try to close this MR and redo in that order?
Comment #54
tedbowSetting to needs work because of PHPCS fail in last commit https://www.drupal.org/pift-ci-job/2105914
Comment #55
paulocsComment #56
tedbow@paulocs thanks starting a new MR from the existing patch!
Needs work for my merge request comments.
Comment #58
tedbowThis looks almost done to me.
\Drupal\file\FileUsage\FileUsageBase::getReferences()and the existing version offile_get_file_references()and confirmed they were the same expect for changes needed to move it to a class.\Drupal\file\FileUsage\FileUsageInterface::getReferences()matches the doc offile_get_file_references()editor_file_download()still has references tofile_get_file_references()in its docComment #59
phenaproximaThanks, @tedbow! Fixed that old reference.
Comment #60
tedbow#58.3 was fixed. Will RTBC when tests are green
Comment #61
phenaproximaHiding previous patches in favor of the merge request.
Comment #62
tedbowLooks good!
Comment #63
paulocsI merged branch '9.3.x' into 3035352-deprecate-filegetfilereferences so MR could be mergeble.
Comment #64
alexpottComment #68
ericgsmith commentedI have made a start rebasing on 10.1.x
Apologies for moving away from the open MR - Its against 9.3.x and I couldn't see how to change the MR to 10.x - it looks like I would have to create a new MR anyway, but if there's a way to change the MR to go against 10.1.x I can push these changes to that branch.
This patch takes the MR at bf95950f18f6960ddbd87b84df22dcced653066a (prior to 9.3.x merge commit) and
- Rebased onto 10.1.x
- Update deprecation warnings to deprecating in 10.1,0 removing in 11.0.0
- Addresses feedback from https://git.drupalcode.org/project/drupal/-/merge_requests/857#note_32161 , https://git.drupalcode.org/project/drupal/-/merge_requests/857#note_32162 , https://git.drupalcode.org/project/drupal/-/merge_requests/857#note_32198
I believe the only comment in the MR not addressed is https://git.drupalcode.org/project/drupal/-/merge_requests/857#note_32197 so leaving as needs work.
Comment #69
ericgsmith commentedOops, missing the change to file.services.yml in that one - ignore the patch above.
Comment #70
_utsavsharma commentedComment #71
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Did not test but looking at the code
For new properties think it would be nice to add typehints
CI failures in #69
Reading the CR and think it could use some tweaks. The 3 functions are deprecated but the before/after only referes to file_get_file_references() correct? And it's being replaced by dependency injection?
The other 2 seemed perfectly covered by the last sentence.
Comment #72
nikhil_110 commentedTry to Fix Cs issue & re-roll patch #69
Comment #73
nikhil_110 commentedComment #74
smustgrave commentedChange record updates still need to happen.
Comment #75
ericgsmith commentedShould this be a memory cache https://www.drupal.org/project/drupal/issues/3047289Edit - removing this as it seems there are many examples of using field properties for things like this.
Unless I'm missing something this param doesn't appear to work as described - its only used for the cache key
Comment #76
ericgsmith commentedComment #77
ericgsmith commentedComment #78
kim.pepperAdding related issues
#3361361: file_get_file_references does not return correct results when using $field param
#1805690: file_get_file_references() is rather bogus
Comment #79
kim.pepperComment #80
ericgsmith commentedReviewed this issue at the DrupalSouth sprint day.
There are some issues with the current implementation of file_get_file_references are still an issue with the current patch.
There are some issues with the optional parameters - namely
As previously noted in #64 core is not making use of this filtering ability - doing a review of contrib I could not find any usage of filtering by field, and could only find 1 usage of filtering by type (https://www.drupal.org/project/protected_file). It may be worth discussing deprecating these without replacement?
Another possibility raised was that the function could be deprecated without replacement if core can provide a generic entity usage API. I have added a related issue #3361364 for this.
Comment #81
berdir#1452100: Private file download returns access denied, when file attached to revision other than current is the primary related issue I'd say, where I've pointed out similar things on extra arguments and also provided an implementation basically deprecates the age argument as well as it's done as a fallback and implicitly.
> Another possibility raised was that the function could be deprecated without replacement if core can provide a generic entity usage API. I have added a related issue #3361364 for this.
I don't think entity_usage as it is can replace this function, that's not the problem it's trying to solve. The problem it's trying to solve is figure out which field, if any (as it could be referenced by an old revision), references a given file so that field access can be checked on that as well.
Comment #82
kim.pepperLooks like we should postpone on #1452100: Private file download returns access denied, when file attached to revision other than current then.
Comment #83
ericgsmith commentedWhen this is picked back up, we should use a memory cache bin instead of class property.
The existing implementation has a problem with returning stale / outdated data.
Here is a patch that shows the issue, its against core rather than the work here and not completed but most relevant is the test which would still be relevant for this approach. Leaving #72 as the displayed patch as that is still the relevant starting point once this is no longer postponed.
Comment #84
acbramley commentedThis is postponed on #1452100: Private file download returns access denied, when file attached to revision other than current but in https://www.drupal.org/project/drupal/issues/1452100#comment-15209547 @berdir suggested we do it the other way around so we can deprecate the arguments here?
Comment #85
mxr576Comment #86
nicxvan commentedComment #88
berdir#1452100: Private file download returns access denied, when file attached to revision other than current now comes with a replacement service and full deprecation of this function. What's left is the cache invalidation stuff, which could be done in the referenced issue.
Comment #89
berdirI think we can go ahead and close this as a duplicate now.