I think I've found the issues with the database and S3 not staying in sync, as referenced here: https://www.drupal.org/project/advagg/issues/2972593
I have two patches which I will post in separate threads. This one adds some code to the advagg_rename function.
Instead of using the PHP rename function, I'm using the public rename function available in the S3fsStreamWrapper. The benefit of using this function is that it calls the waitUntilFileExists function, ensuring the process is not officially completed until the file actually exists in S3.
Another point to mention is advagg_rename uses drupal_realpath. I'm skipping this for s3fs, because as it says on its page:
The use of drupal_realpath() is discouraged, because it does not work for remote URIs. Except in rare cases, URIs should not be manually resolved.
https://api.drupal.org/api/drupal/includes%21file.inc/function/drupal_re...
Please review and let me know if you have questions, thanks.
Comments
Comment #2
sgdev commentedI noticed in the code it is mentioned about wanting to keep the rename command local and atomic.
Also, I've done more research and I don't think this is the cause of the problems I am seeing (I'm going to detail my findings on another post).
So if you'd prefer to close this issue and not add the patch, I'm totally ok with that. Let me know.
Comment #4
mikeytown2 commentedUsing the s3 rename is ok here as it's a fairly unique situation.
Comment #5
mikeytown2 commentedThinking about this and should it cascade through and try rename then file_unmanaged_move and then the rename method if it exists? That way it'd work for other stream wrappers.
Comment #6
sgdev commentedThat sounds like a good idea. Let me create a new patch for review.
Comment #7
sgdev commentedSee the attached patch. I moved
file_unmanaged_moveahead of@rename. Let me know if you are ok with that.Also moved the creation of
$real_sourceand$real_destinationinside the conditional. No need to define them until they are needed.Comment #9
sgdev commentedNot sure the
Call to a member function rename() on booleanis a true error?I get this in my IDE too, and see it in other modules like Transliteration that call
$wrapper->rename().Comment #10
mikeytown2 commentedComment #11
mikeytown2 commentedComment #12
mikeytown2 commentedComment #13
sgdev commentedHave been using #12 for the past 18 months on live sites with no issues... setting as RTBC?
Comment #15
mikeytown2 commentedComment #17
sgdev commented@mikeytown2, thanks for committing #12.
It seems like the code committed in #14 is something different... new code I've never seen before for
advagg_js_compress_do_it.Just wanted to make sure this wasn't committed by accident?
https://git.drupalcode.org/project/advagg/commit/62d6c05
Comment #18
thallesI must mark it fixed, for lack of interaction.
Comment #19
thalles