Skip to content

Tag person categories by their URL instead of crashing - #332

Open
mrcgrtz wants to merge 1 commit into
indieweb:trunkfrom
mrcgrtz:fix/category-objects-as-terms
Open

Tag person categories by their URL instead of crashing#332
mrcgrtz wants to merge 1 commit into
indieweb:trunkfrom
mrcgrtz:fix/category-objects-as-terms

Conversation

@mrcgrtz

@mrcgrtz mrcgrtz commented Aug 24, 2026

Copy link
Copy Markdown

Another error I found in my logs:

trim(): Argument #1 must be of type string, array given in wp-includes/taxonomy.php

A category is not always a string. Person tags are sent as nested h-cards, for example by OwnYourSwarm on a check-in:

"category": [ { "type": [ "h-card" ], "properties": { /* … */ } } ]

mp_to_wp() passed every category it could not resolve to an existing WordPress category straight into tags_input, so the h-card array reached trim() inside wp_set_object_terms() and raised a TypeError on PHP 8. That happens inside wp_insert_post() after the row is written but before meta_input is stored, so the post survived without any mf2_* or geo_* value and the request died with a 500.

Resolve an h-card to its URL and tag the person with that. An h-card without a URL, or a nested object of some other kind, yields no term rather than a fatal. Scalar categories keep their existing handling, including integers, which WordPress resolves as term IDs.

The full h-card is unaffected in the mf2_category meta: store_mf2() builds that from $this->input rather than from these arguments, so people tagged in a Swarm check-in stay recorded in full, and now get a post tag too.

Fixes #329

A category is not always a string. Person tags are sent as nested h-cards,
for example by OwnYourSwarm on a check-in:

    "category": [ { "type": [ "h-card" ], "properties": { … } } ]

mp_to_wp() passed every category it could not resolve to an existing
WordPress category straight into tags_input, so the h-card array reached
trim() inside wp_set_object_terms() and raised a TypeError on PHP 8. That
happens inside wp_insert_post() after the row is written but before
meta_input is stored, so the post survived without any mf2_* or geo_* value
and the request died with a 500.

Resolve an h-card to its URL and tag the person with that. An h-card without
a URL, or a nested object of some other kind, yields no term rather than a
fatal. Scalar categories keep their existing handling, including integers,
which WordPress resolves as term IDs.

The full h-card is unaffected in the mf2_category meta: store_mf2() builds
that from $this->input rather than from these arguments, so the people
tagged in a check-in stay recorded in full, and now get a post tag too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

An h-card in category fatals mid-insert and strands the post without meta

1 participant