Problem/Motivation

Local files linked in HTML (and possibly other references) are not being tracked since the release of beta 24.

Specifically, this commit altered the public file pattern in a way that seems to be incompatible with local file systems. For example, what used to be {^/?sites/default/files/} is now {^/sites/default/files//}. The double slash at the end results in no matching in the getFileFromPath method.

https://git.drupalcode.org/project/entity_usage/-/commit/571be2c4ff7add4...

Steps to reproduce

Track HTML links and insert a link to a public file on a local file system into a text field on a node. Saving the node does not save any tracking for the target file.

Proposed resolution

Revert the commit in question while a new approach, with better test coverage, is added.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Command icon 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

john.oltman created an issue. See original summary.

john.oltman’s picture

StatusFileSize
new942 bytes

Do not use

john.oltman’s picture

StatusFileSize
new1.23 KB
john.oltman’s picture

Title: Linked files are no longer tracked » Local linked files are no longer tracked
john.oltman’s picture

Issue summary: View changes
ludo.r’s picture

I confirm the issue and patch #3 solves the issue.

ludo.r’s picture

Status: Active » Needs review
marcoscano’s picture

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

Your patch is only reverting what has been done in #3514883: Assertion fails when using external stream wrappers (e.g. s3fs) in PublicFileIntegration
Unless I'm reading things very wrong, wouldn't this fix be re-introducing the bug fixed there?
I believe we first need to make sure we have test coverage for both bugs, and then come up with a fix that is compatible with both of them.

john.oltman’s picture

There is only one bug, not two. The bug in #3514883: Assertion fails when using external stream wrappers (e.g. s3fs) in PublicFileIntegration was not fixed properly, creating a regression covered by this issue. We need a solution to that bug that does not cause a regression, at which point both issues (the original bug issue, and this regression issue) will be solved.

Yes, applying the patch simply reverts the change that caused the regression, which is why I did not originally mark this issue as Ready for Review, @ludo.r did a few days ago. I agree that Needs Work is the correct status at this point. The next step is for someone to develop a fix for the original bug that does not cause a major regression. That fix would ideally be an MR attached to this issue.

codebymikey made their first commit to this issue’s fork.

codebymikey’s picture

Status: Needs work » Needs review

Can someone making use of s3fs confirm that the current MR addresses their original bug?

This works for me, and should theoretically work for s3fs too, as the trailing / is still persisted.

Unless someone else has time to create a test for this, I think the MR should be quickly tested and merged, or the original commit reverted, as the module is currently in an unusable state at the moment for basic core functionality in order to cater for a contrib module, and has silently been for months now.

Tests can always be added later without closing the issue, but I believe site builders will also need to be made aware that their entity usage stats might currently be inaccurate and will need to be reindexed, as some of my sites heavily rely on the entity usage count to be accurate in order for users to confidently delete them, but that trust might now be eroded with this issue.

  • alexpott committed 54ebfe86 on 5.x
    fix: #3521603 Local linked files are no longer tracked
    
    By: john.oltman...

  • alexpott committed 561ed0e0 on 8.x-2.x
    fix: #3521603 Local linked files are no longer tracked
    
    By: john.oltman...
alexpott’s picture

Status: Needs review » Needs work

I've merged @codebymikey's MR as I agree this is the correct fix. Yes we definitely should add some test coverage for this feature so we don't break it again.