Skip to content

Fix PublishPress Revisions filter corrupting field names on upload (WP-1026) - #639

Open
vsolovei-smartling wants to merge 5 commits into
masterfrom
WP-1026-revisions-filter-fix
Open

vsolovei-smartling wants to merge 5 commits into
masterfrom
WP-1026-revisions-filter-fix

Conversation

@vsolovei-smartling

@vsolovei-smartling vsolovei-smartling commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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 given

Root cause

PublishPressRevisions hooked sanitizeTargetField onto smartling_metadata_string_process at 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, so MetaFieldProcessorManager::handlePostTranslationFields received the value as its name:

  • array values (for example the revision meta _rvy_updated_by) raised a TypeError;
  • scalar values silently selected the wrong processor;
  • the post_mime_type reset never took effect.

The existing unit tests called sanitizeTargetField directly, so the real filter chain was never exercised.

Fix

  • New smartling_target_entity_field filter (ExportedAPI::FILTER_SMARTLING_TARGET_ENTITY_FIELD) that takes the value first, then the field name, then the submission. SmartlingCoreTrait applies 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.
  • UploadJob logs upload failures at ERROR with submission ids, exception class and file:line (previously only a NOTICE).
  • Changelog entry under 5.8.2 in readme.txt, and version bumped to 5.8.2 (composer.json, smartling-connector.php, readme.txt stable 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

vsolovei-smartling and others added 5 commits November 3, 2026 18:05
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant