Push a full avatar URL when a group is edited - #901
Open
edwh wants to merge 1 commit into
Open
Conversation
Editing a group pushed group_avatar_url to WordPress as
env('UPLOADS_URL').'mid_'.$path. UPLOADS_URL was a constant in the
pre-Laravel Fixometer and was never carried over, so the value collapsed
to a bare "mid_xxx.png" with no host, and WordPress rendered an image
that 404s. Approving a group wrote a good URL via groupImagePath(); the
next edit overwrote it with a broken one. 22 of the 623 group pages on
therestartproject.org are currently affected.
EditWordpressPostForGroup now reads its whole payload off the group,
which updateGroup has already saved, rather than off the event array, so
it can't drift from CreateWordpressPostForGroup again. That also
removes a latent Undefined array key crash on a partial payload.
Adds wordpress:group:fix-avatars to backfill the posts that are already
wrong. Its WordpressClient is injected into handle() rather than the
constructor: Artisan resolves commands when it boots, so a constructor
dependency is pinned to whatever was bound at boot time, and a test
binding a mock afterwards was ignored and made a live XML-RPC call.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WRv64fqMT3fAveD6NFgnmR
|
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.


The bug
Group avatars are broken on therestartproject.org for any group that has been edited since the Laravel port.
<img src="mid_16527798588f105814c6992b17930bf453ab9783610a5c8fb95489.png"><img src="https://restarters.net/uploads/mid_1740242182255d38b64da3e4f70b8a1c13030c3a3f4ab44dbf11313.jpg">Root cause
The create and edit paths built
group_avatar_urltwo different ways.CreateWordpressPostForGroupuses the model:EditWordpressPostForGroupused the event payload, whichAPI\GroupController::updateGroupbuilt like this:UPLOADS_URLhas never existed in the Laravel app. It was a PHP constant in the pre-Laravel Fixometer(
f0dac97) and was not carried over — it is not in.env,.env.example,config/, or any of the flyconfigs. So
env('UPLOADS_URL')returnsnulland the pushed value collapses to a baremid_….png, with nohost and not even the
/uploads/directory. WordPress renders that verbatim, so the image 404s.Approving a group wrote a good URL; the next edit overwrote it with a broken one. That's exactly the
difference between the two pages above.
(The
elsebranch had the same problem, and sent the literal string'null'for a group with no image.)The fix
EditWordpressPostForGroupnow reads its payload off the group — whichupdateGrouphas already saved —instead of off the event array, so it can't drift from
CreateWordpressPostForGroupagain. That also removesa latent
Undefined array keycrash: the listener indexed$data['website'],$data['latitude']etc.directly, so any caller firing
EditGroupwith a partial array would have failed the queued job.The dead
UPLOADS_URLURL-building inAPI\GroupController::updateGroupis gone; the image upload itself(the only part with a side effect) stays.
Backfill
php artisan wordpress:group:fix-avatarsWalks groups with a
wordpress_post_id, reads the post'sgroup_avatar_url, and rewrites any value thatisn't an absolute URL to
$group->groupImagePath(). It sends only that one custom field, carrying thefield's existing WordPress id so the value is replaced rather than duplicated.
The client is injected into
handle()rather than the constructor. Artisan resolves commands when it boots,which can be long before the command runs — with a constructor dependency the command kept whatever was bound
at boot time, and a test binding a mock afterwards got ignored and made a real XML-RPC call out to
therestartproject.test. That only showed up when another test had already booted Artisan (viaprocessQueuedNotifications()inTestCase::setUp), so the test passed alone and failed in suite order.Suggested run:
Scale on live
I swept all 623 group pages in https://therestartproject.org/group-sitemap.xml. 22 are broken; the other 601
are fine.
So a targeted run is also an option:
Tests
WordpressGroupPushTestgains three cases: the avatar pushed on edit must be the absolutegroupImagePath(), a group with no image must still get an absolute URL rather than'null', and create andedit must push the same value. All three fail on the old listener (the first with
Failed asserting that two strings are equal).WordpressFixGroupAvatarsTestcovers the backfill: relative paths and the literal'null'are rewritten,already-correct posts are left alone,
--dry-runwrites nothing, a group whose post has been deleted isreported without aborting the run, and the command refuses when
wordpress_integrationis off.Not affected
The event/party push (
CreateWordpressPostForEvent,EditWordpressPostForEvent) never sends an image field,and
SyncGroupsdoesn't touchgroup_avatar_url, so neither could cause or repair this.🤖 Generated with Claude Code
https://claude.ai/code/session_01WRv64fqMT3fAveD6NFgnmR