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.
if (!file_exists($local) || update_delete_file_if_stale($local)) {
return system_retrieve_file($url, $local, FALSE, FILE_EXISTS_REPLACE);
}
else {
return $local;
}
We'll never use the local cache of a remote file since update_delete_file_if_stale() is a void function.
The patch should:
- change update_delete_file_if_stale() to return TRUE if something is deleted and FALSE if not.
- update UpdateDeleteFileIfStaleTest to test the return value.
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Create a patch | Y | Instructions | |
Add automated tests (if possible) | Y | Instructions | |
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Y | Instructions |
Comment | File | Size | Author |
---|---|---|---|
#48 | 2303323-48.patch | 2.74 KB | dww |
#48 | 2303323-48.test-only.patch | 3.52 KB | dww |
|
Comments
Comment #1
alexpottComment #2
alexpottComment #3
joshi.rohit100please review now.
Comment #4
BerdirAlways use two spaces instead of tabs.
There must be an empty line above @return and @return must be followed by the type (bool)
Comment #5
er.pushpinderrana CreditAttribution: er.pushpinderrana commentedPlease review updated patch.
Comment #6
amitgoyal CreditAttribution: amitgoyal commentedPlease review update patch with minor fixes.
Comment #9
vlad.n CreditAttribution: vlad.n commentedupdate_manager_file_get-fetch-stale-files-2303323-6.patch still applies cleanly at f07bcff .
Comment #10
nuwe CreditAttribution: nuwe commentedupdate_manager_file_get-fetch-stale-files-2303323-6.patch still applies cleanly at f07bcff
Comment #11
star-szrThis should have a test-only patch uploaded to show that the updated test fails and catches the bug.
https://www.drupal.org/contributor-tasks/write-tests
Comment #12
tadityar CreditAttribution: tadityar commentedAdded the test-only patch.
Comment #14
tadityar CreditAttribution: tadityar commentederr.. that one was supposed to fail anyway
Comment #15
dimaro CreditAttribution: dimaro at La Drupalera by Emergya commentedI reviewed this issue and for me work as expected. Also it follows the coding standars. RTBC?
Comment #16
jp.stacey CreditAttribution: jp.stacey at Magnetic Phield commentedLooking at this as part of Sprint Weekend 2016.
Comment #17
jp.stacey CreditAttribution: jp.stacey at Magnetic Phield commentedThe patch as it stands does test the return value of
update_delete_file_if_stale()
. However, it no longer tests that the file is actually deleted!I've modified the test so it checks:
1. the file exists.
2. trying to delete a non-stale file returns FALSE.
3. the file is deleted when stale.
4. trying to delete a stale file returns TRUE.
All six assertions in the test pass on my dev build, so submitting for review.
Comment #20
quietone CreditAttribution: quietone as a volunteer commentedThe patch applies to 8.2.x and looks good to me. The added tests properly checks if the file was deleted and the status of the returned boolean.
Also, since #17 doesn't include a fail patch, I've added one. Also retesting #17 on 8.2.x
Comment #22
quietone CreditAttribution: quietone as a volunteer commentedSo, the fail patch in #20 shows that even though the stale file is deleted a success (true) is not returned. The patch in #17 is the fix and looks good to me.
But this is tagged with Needs change record, so there is still work to do.
Comment #23
quietone CreditAttribution: quietone as a volunteer commentedRE uploading the patch in #17, the latest working one, so this can be set to NR.
Does this need a change record?
Comment #29
quietone CreditAttribution: quietone as a volunteer commentedAn attempt at a reroll and move to 8.9.x
Comment #30
dwwJust seeing this issue for the first time.
Mostly looks great. Love the expanded test coverage. The change itself is small and good. One very minor quibble:
We don't need "now" twice in this comment.
Otherwise, I wonder if we want a better title for this issue for git history reasons. The title talks about update_manager_file_get(), but only change here is in update_delete_file_if_stale().
Finally, I agree we probably need a CR for this.
Thanks!
-Derek
Comment #32
dwwA little git archeology. This bug came in when update_delete_file_if_stale() was first added at #605318: Add some garbage collection to the update manager. Not sure how we missed it. ;) That issue was re-opened at #605318-67: Add some garbage collection to the update manager for exactly this problem. I'm going to go ahead and re-close that one in favor of this, since the patch here is in better shape than the latest over there. However, crediting Alan D. so their contribution at #605318 is acknowledged.
Comment #33
iyyappan.govindHi Dww,
As per suggestion I have updated the patch.
Before
Now
Thanks
Comment #34
iyyappan.govindComment #35
iyyappan.govindChanging status
Comment #36
dwwAttempt at resolving #30 with a more complete title.
Sorry I didn't notice before, but one other minor optional change:
I don't think these comments are needed given the assertions themselves.
If we keep them, we don't need "As before, ".
However, NW because it still needs the CR.
Thanks!
-Derek
Comment #37
jungleIn addition to #36, assertFileNotExists() and assertFileNotExists() are more appropriate here.
Comment #38
jungleFiled a new issue for #37, as there are more to fix.
Comment #39
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedComment #40
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedUpdated test changes, Patch created, Please review.
Comment #41
dwwShould remove this comment.
phpunit assertion messages should explain when the assertion fails. (Messages used to be positive in the SimpleTest world, but are negative now).
Remove this.
Fix this (see above).
https://www.drupal.org/pift-ci-job/1664921
/var/lib/drupalci/workspace/jenkins-drupal_patches-43446/source/core/modules/update/update.module ✗ 1 more
line 839 Additional blank lines found at end of doc comment
Attached fixes all of this. But still NW for the change record. ;)
Comment #42
dwwAdded the draft CR:
https://www.drupal.org/node/3131432
Needs version / branch info filled in when published, depending on how far back this gets backported.
RTBC?
Thanks
-Derek
Comment #43
dwwSlightly improved the @return docs (IMHO). ;) Canceled the testbot run on #41. Let's use this, instead.
Comment #45
dwwSelf-review. Attached fixes all this:
Wants , after "During testing".
A) Should come right after we get the value for
$deleted
.B) We don't need the assertion message here at all. It's obvious from the comments, and we're trying to get rid of those.
80 char wrapping is off.
Same as above:
- Move directly under update_delete_file_if_stale() call.
- Remove message.
Comment #46
dwwSorry, forgot test-only + full. This should be red/green candy.
Comment #47
jungleThanks @dww.
2 ~ 3 lines are duplicate, should the comments be reworded/adjusted?
Not sure the following are in scope:
REQUEST_TIME
with\Drupal::time()->getRequestTime()
?Otherwise, it's good to me.
Comment #48
dww@jungle: Thanks for the review! Re: #47:
1. Yeah, probably a good move. Fixed here. How's this?
2.1: IMHO, out of scope. That should be handled (everywhere) when core properly deprecates
REQUEST_TIME
.2.2: Nope, we're referring to the value returned by filectime(). But to clarify, changing from
$filectime
tofilectime()
. ;)Re: #46: I missed in drupalci.yml, this test-only should properly fail...
RTBC? 🤞
Comment #49
jungleTo make it clear. I meant changing
$filectime = filectime($path);
to$file_ctime = filectime($path);
, agree on that both 47.2.1 and 47.2.2 are out of scope.The change looks good. #46 passed, #48 should pass too. So setting to RTBC. Thanks @dww!
Comment #50
dwwRe: #49: Oh, sorry, I totally missed the context you were quoting in #47.2. Whoops. But yeah, same answer. ;) Still out of scope.
Thanks for the review and RTBC!
Cheers,
-Derek
Comment #51
alexpottCommitted f96378a and pushed to 9.1.x. Thanks!