From 0a13d27d6f4e4948431a0df6108b3ce30135907f Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 14 Mar 2026 16:32:22 +0000 Subject: [PATCH] Expand webmentions source and target columns to text Long brid.gy Bluesky source URLs exceed 255 characters, causing SQLSTATE[22001] errors. Changed source and target from varchar(255) to text (no performance impact in PostgreSQL). Co-Authored-By: Claude Sonnet 4.6 --- ...pand_webmentions_source_target_to_text.php | 26 +++++++++++++++ database/schema/pgsql-schema.sql | 4 +-- tests/Unit/Jobs/ProcessWebMentionJobTest.php | 32 +++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2026_03_14_000000_expand_webmentions_source_target_to_text.php diff --git a/database/migrations/2026_03_14_000000_expand_webmentions_source_target_to_text.php b/database/migrations/2026_03_14_000000_expand_webmentions_source_target_to_text.php new file mode 100644 index 00000000..de643ab0 --- /dev/null +++ b/database/migrations/2026_03_14_000000_expand_webmentions_source_target_to_text.php @@ -0,0 +1,26 @@ +text('source')->change(); + $table->text('target')->change(); + }); + } + + public function down(): void + { + Schema::table('webmentions', function (Blueprint $table) { + $table->string('source')->change(); + $table->string('target')->change(); + }); + } +}; diff --git a/database/schema/pgsql-schema.sql b/database/schema/pgsql-schema.sql index 6dae72e5..d1f926a3 100644 --- a/database/schema/pgsql-schema.sql +++ b/database/schema/pgsql-schema.sql @@ -723,8 +723,8 @@ ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id; CREATE TABLE public.webmentions ( id integer NOT NULL, - source character varying(255) NOT NULL, - target character varying(255) NOT NULL, + source text NOT NULL, + target text NOT NULL, commentable_id integer, commentable_type character varying(255), type character varying(255), diff --git a/tests/Unit/Jobs/ProcessWebMentionJobTest.php b/tests/Unit/Jobs/ProcessWebMentionJobTest.php index e3754b86..549dee60 100644 --- a/tests/Unit/Jobs/ProcessWebMentionJobTest.php +++ b/tests/Unit/Jobs/ProcessWebMentionJobTest.php @@ -195,6 +195,38 @@ class ProcessWebMentionJobTest extends TestCase ]); } + #[Test] + public function webmention_with_long_source_url_gets_saved(): void + { + Queue::fake(); + + $parser = new Parser; + + $html = <<<'HTML' +
+ I liked a note. +
+ HTML; + $html = str_replace('href="', 'href="' . config('app.url'), $html); + $mock = new MockHandler([ + new Response(200, [], $html), + ]); + $handler = HandlerStack::create($mock); + $client = new Client(['handler' => $handler]); + + $note = Note::factory()->create(); + // Simulate a long brid.gy Bluesky source URL (well over 255 characters) + $source = 'https://brid.gy/comment/bluesky/did:plc:n3jhgiq2ykctnpgzlm6p6b25/at%253A%252F%252Fdid%253Aplc%253An3jhgiq2ykctnpgzlm6p6b25%252Fapp.bsky.feed.post%252F3mfekjuhykb2k/at%253A%252F%252Fdid%253Aplc%253Afsfuwigo5juzdwp23hyianzg%252Fapp.bsky.feed.post%252F3mfemw4rrvs2t'; + + $job = new ProcessWebMention($note, $source); + $job->handle($parser, $client); + + $this->assertGreaterThan(255, strlen($source)); + $this->assertDatabaseHas('webmentions', [ + 'source' => $source, + ]); + } + #[Test] public function webmention_repost_gets_deleted_when_repost_of_value_changes(): void {