Repository navigation
Fix sync loop flagging PDFs and other files without dimensions - #1401
Open
gabrielcld2 wants to merge 1 commit into
Open
gabrielcld2 wants to merge 1 commit into
gabrielcld2 wants to merge 1 commit into
Conversation
Files without width and height (PDF, audio, documents) got the error 'Sync loop detected: the "delivery" sync state could not be saved.' when uploaded in the admin. Preparing their sync asks for the attachment URL, and the admin URL filter called back into Media::cloudinary_id(), which prepared the sync again until the loop guard tripped. Answer that nested call with the local URL instead. On upgrade from 3.3.9, clear the delivery loop errors it flagged so those files sync. Adds PHPUnit regression tests and an e2e test that uploads a PDF through the Media Library. Fixes #1397
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1397
Approach
Since 3.3.9, files without width and height (PDF, audio, documents) uploaded in the admin get the sync error
Sync loop detected: the "delivery" sync state could not be saved.and never sync to Cloudinary.Preparing the sync of such a file asks for its URL, because no sized URL exists for it. In the admin, the attachment URL filter calls back into
Media::cloudinary_id(), which prepared the sync again. That nesting used to stop becauseUtils::is_saving_metadata()checkeddid_action(). #1303 changed it todoing_action(), so the nesting continued until the loop guard from #1328 stopped it and saved the error.Media::cloudinary_id()now caches a placeholder for the attachment before it prepares the sync. A nested call during preparation gets the local URL instead of preparing the sync again. The outer call then replaces the placeholder with the real ID.Sync::clear_delivery_loop_errors()removes that exact error, in English and in every installed language, so the affected files sync again. It doesn't touch other sync errors, or loop errors on other sync types.Sync::get_loop_error_message(), so the guard and the cleanup use the same string.QA notes
res.cloudinary.comURL.Automated:
test-media-cloudinary-id-reentry.php(6 tests). The 2 regression tests fail without the fix. The full suite passes.cloudinary-document-sync.spec.jsuploads a PDF through the Media Library. The other specs upload through REST, which skips the sync preparation, so they can't catch this. This spec fails without the fix, with the same error the customer reported.