Repository navigation
Fix PublishPress Revisions filter corrupting field names on upload (WP-1026) - #639
Open
vsolovei-smartling wants to merge 5 commits into
Open
vsolovei-smartling wants to merge 5 commits into
vsolovei-smartling wants to merge 5 commits into
Conversation
…P-1026) The revisions extension hooked sanitizeTargetField onto smartling_metadata_string_process at priority 5 and returned the field value. WordPress threads the first argument through the callback chain, and that argument is the field name, so MetaFieldProcessorManager received the value as the name. An array value such as _rvy_updated_by raised a TypeError, which failed the submissions before any file was uploaded and left the batch empty. For scalar values the wrong processor was silently picked, and the revision mime type was never actually reset. Target entity fields now go through a dedicated smartling_target_entity_field filter that takes the value first, and the extension hooks that instead. Upload failures are also logged at error level with class and location. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e (WP-1026) failItem already logs a notice per failed submission, so the separate error line added earlier duplicated it. failItem now takes a log level, and the exception path passes error with the exception class and location. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Problem
With PublishPress Revisions active, translation uploads could fail before the file was sent, leaving the Smartling job batch empty. The submission failed with:
MetaFieldProcessorManager::getProcessor(): Argument #1 ($fieldName) must be of type string, array givenRoot cause
PublishPressRevisionshookedsanitizeTargetFieldontosmartling_metadata_string_processat priority 5 and returned the field value. WordPress passes the first argument of a filter through the callback chain, and that argument is the field name, soMetaFieldProcessorManager::handlePostTranslationFieldsreceived the value as its name:_rvy_updated_by) raised aTypeError;post_mime_typereset never took effect.The existing unit tests called
sanitizeTargetFielddirectly, so the real filter chain was never exercised.Fix
smartling_target_entity_fieldfilter (ExportedAPI::FILTER_SMARTLING_TARGET_ENTITY_FIELD) that takes the value first, then the field name, then the submission.SmartlingCoreTraitapplies it after the metadata filter for each target entity field.PublishPressRevisions::sanitizeTargetField($value, $name, $submission)now hooks that filter and no longer touches the metadata filter.UploadJoblogs upload failures at ERROR with submission ids, exception class and file:line (previously only a NOTICE).readme.txt, and version bumped to 5.8.2 (composer.json,smartling-connector.php,readme.txtstable tag).Tests
Written first and watched fail, including a filter-chain test that reproduces the
TypeError. Full unit suite: 788 tests passing. Integration tests not run.Jira: WP-1026
🤖 Generated with Claude Code