Skip to content

Fix TTS cache bug#1123

Open
dkotter wants to merge 2 commits into
developfrom
fix/tts-cache
Open

Fix TTS cache bug#1123
dkotter wants to merge 2 commits into
developfrom
fix/tts-cache

Conversation

@dkotter

@dkotter dkotter commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Description of the Change

While reviewing code for something else, found a potential bug in our Text To Speech Feature. When that Feature is run, we check to see if we have cached results (to avoid re-generating speech if the content hasn't changed). In that case, we return the attachment ID of the existing audio.

But we weren't checking for this when our callback runs, we just assumed it would always give us the audio file, not an attachment ID. This could potentially result in the existing audio file being wiped and a corrupt one being added (noting this is theoretical, didn't seem to actually be this dramatic in my testing).

This PR fixes it by checking the result returned and if that's an ID instead of a the actual audio, we don't run our save method.

How to test the Change

I couldn't actually reproduce but the steps would be something like this:

  1. Turn on the Text to Speech Feature
  2. Create a post and generate speech
  3. Don't change any content and re-trigger speech generation
  4. The original audio file should still be there and there shouldn't be a new, broken audio file

Changelog Entry

Fixed - Ensure we don't overwrite a valid audio file when data already exists and content hasn't changed.

Credits

Props @dkotter

Checklist:

Open WordPress Playground Preview

@dkotter dkotter added this to the 3.9.0 milestone Jun 18, 2026
@dkotter dkotter self-assigned this Jun 18, 2026
@dkotter dkotter requested review from a team and jeffpaul as code owners June 18, 2026 18:51
@github-actions github-actions Bot added the needs:code-review This requires code review. label Jun 18, 2026
@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant