@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix content: <http://purl.org/rss/1.0/modules/content/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

<https://lhero.org/portfolio/lh-addresses/>
  a sioc:Post ;
  dc:title "Legacy sync" ;
  dcterms:identifier 155318 ;
  dc:modified "2026-11-22T11:40:59Z"^^xsd:dateTime ;
  dc:created "2026-11-22T03:54:58Z"^^xsd:dateTime ;
  sioc:link <https://lhero.org/portfolio/lh-addresses/legacy-sync/> ;
  sioc:has_creator <https://lhero.org/author/1/#account> ;
  sioc:has_container <https://lhero.org/#posts> ;
  content:encoded """<ul class="lh_portfolio-meta"><li><strong>Part of:</strong> <a href="https://lhero.org/portfolio/lh-addresses/">LH Addresses</a></li></ul>
<p class="wp-block-paragraph">The bridge from LH Profile Page&#8217;s <code>lh_profile-*</code> address meta (lh-tasks #148769). Since 0.11.0 (stage 5, 22 Nov 2026) the tables are the only store. Nothing mirrors addresses into the meta any more, so the meta keeps whatever it held when the mirror stopped, until it is deleted (stage 6, asking Peter first). Every writer calls <code>set_user_parts()</code>, every reader calls <code>get_meta_value()</code>, <code>find_user_ids()</code> or <code>own_residential_subquery()</code>, and a stray write to the meta is still caught and recorded.</p>



<h2 class="wp-block-heading">Writing through LH Addresses</h2>



<p class="wp-block-paragraph"><code>LH_Addresses_Legacy_Sync::set_user_parts( $user_id, $parts )</code> takes some or all of <code>address_line1</code>, <code>locality</code>, <code>postal_code</code>, <code>administrative_area</code> and <code>country_code</code> as typed (&#8221; clears a part; the country may be a name such as Australia). <code>address_from_table()</code> overlays them on the member&#8217;s current own residential address in the tables, so parts not given keep their current value there, and the result is saved. Returns created, replaced, unchanged or ended, or a WP_Error. Since 0.11.0 nothing is written to the meta. Before that, the parts were overlaid on the meta and mirrored back into it (0.7.0 to 0.10.0).</p>



<ul class="wp-block-list">
<li><strong>created</strong>: the member had no own residential address; one is created, and LH Membership gives it to every club they are a member of (2.112.0).</li>



<li><strong>replaced</strong>: the address differs; the old row is ended and kept, and clubs the member still belongs to move to the new one.</li>



<li><strong>unchanged</strong>: nothing is written.</li>



<li><strong>ended</strong>: every part is empty; the own-book residential use is ended, so the member has no current address. Clubs keep what they were given (Peter, 22 Nov 2026).</li>
</ul>



<p class="wp-block-paragraph">Writers, each storing all the parts of one save together: LH Profile Page&#8217;s field saver (3.22.0; profile forms, admin forms, check-ins, CRM, update-user-profile) and fill-fields (3.23.0; create-or-fill-user), LH Mysideline&#8217;s CSV import (1.6.0) and LH Multisite Importer (1.0.2). All three plugins require LH Addresses and have had no direct-meta fallbacks since stage 4 (LH Profile Page 3.26.0, LH Mysideline 1.7.0, LH Multisite Importer 1.1.0). No other code on the network writes the keys.</p>



<h2 class="wp-block-heading">Reading through LH Addresses</h2>



<p class="wp-block-paragraph">Three readers, each taking an LH Profile Page address meta key and answering from the member&#8217;s current own residential address. Each returns null when the key is not an address key or the tables are not at their current schema. LH Profile Page then reads usermeta after <code>get_meta_value()</code> and <code>own_residential_subquery()</code>, because those code paths also serve non-address keys (gender, birthdate). search-users treats a null from <code>find_user_ids()</code> as no matches (since 3.26.1).</p>



<ul class="wp-block-list">
<li><strong><code>get_meta_value( $user_id, $meta_key )</code></strong> (0.8.0): the value, in place of <code>get_user_meta()</code>. Street, town, postcode and state as stored (the state as a subdivision code such as VIC where it was mapped), the country as its English name (<code>country_name()</code>); &#8221; when the member has no address. Rows are cached per request; the cache is emptied on <code>lh_addresses_saved</code>, <code>_replaced</code>, <code>_use_added</code> and <code>_use_ended</code>.</li>



<li><strong><code>find_user_ids( $meta_key, $values, $match )</code></strong> (0.9.0): user IDs matching any of the values, in place of a meta query. <code>partial</code> uses LIKE, <code>exact</code> uses =. A country also matches by its English name (Australia for AU) and a state by its subdivision name (Victoria for VIC), among the countries on file.</li>



<li><strong><code>own_residential_subquery( $meta_key )</code></strong> (0.10.0): SQL for a derived table of <code>user_id</code> and <code>meta_value</code>, one row per user, in place of a usermeta join. Values are as stored, so the state and country are codes.</li>
</ul>



<p class="wp-block-paragraph">Readers moved: LH Profile Page 3.24.0 to 3.26.1 (<code>LH_Profile_Phone_Field::return_user_meta()</code> and so the fill-if-empty checks, CRM, check-ins, reports and update-user-profile; the five address inputs, xProfile and the backend profile table; contact cards; search-users results and filters; Users Insights), and LH Mysideline 1.7.0 (the CSV import&#8217;s fill rule). LH Contacts 0.6.0 refreshes cards on this plugin&#8217;s actions, and LH Profile Page 3.26.2 stopped asking it to watch the address meta keys. fill-fields counts an address part as filled when <code>set_user_parts()</code> succeeds, with no meta readback.</p>



<h2 class="wp-block-heading">Stray writes to the meta</h2>



<p class="wp-block-paragraph"><code>added_user_meta</code>, <code>updated_user_meta</code> and <code>deleted_user_meta</code> on any of the five keys note the user and the key. On <code>shutdown</code> each user&#8217;s written keys are read (a deleted key counts as &#8221;) and overlaid on their address in the tables with <code>address_from_table()</code>, with the same results as <code>set_user_parts()</code>. Keys that were not written are never read, since they are stale; before 0.11.0 all five keys were copied together, which would now roll the other parts back.</p>



<p class="wp-block-paragraph">The first such write per user per request is recorded in the network option <code>lh_addresses_legacy_meta_writes</code> (count, first_at, last_at, and the last 20 with user, key, action and caller; filter <code>lh_addresses_return_legacy_writes_kept</code>). Every entry names code that still writes the meta directly. A quiet record for a while, with the checks in lh-tasks #155341, is the cue to ask Peter about deleting the meta.</p>



<h2 class="wp-block-heading">Retired in 0.11.0</h2>



<p class="wp-block-paragraph">The full copy from the meta to the tables: <code>sync_user()</code> now changes nothing and returns skipped, so the backfill (complete, pass 3: 6,280 users) can no longer write. The <code>lh-addresses/resync-users</code> ability, which ran it on demand, is removed. Both would have copied stale meta over addresses changed since.</p>
"""^^rdf:XMLLiteral ;
  sioc:content """Part of: LH Addresses
The bridge from LH Profile Page&#8217;s lh_profile-* address meta (lh-tasks #148769). Since 0.11.0 (stage 5, 22 Nov 2026) the tables are the only store. Nothing mirrors addresses into the meta any more, so the meta keeps whatever it held when the mirror stopped, until it is deleted (stage 6, asking Peter first). Every writer calls set_user_parts(), every reader calls get_meta_value(), find_user_ids() or own_residential_subquery(), and a stray write to the meta is still caught and recorded.



Writing through LH Addresses



LH_Addresses_Legacy_Sync::set_user_parts( $user_id, $parts ) takes some or all of address_line1, locality, postal_code, administrative_area and country_code as typed (&#8221; clears a part; the country may be a name such as Australia). address_from_table() overlays them on the member&#8217;s current own residential address in the tables, so parts not given keep their current value there, and the result is saved. Returns created, replaced, unchanged or ended, or a WP_Error. Since 0.11.0 nothing is written to the meta. Before that, the parts were overlaid on the meta and mirrored back into it (0.7.0 to 0.10.0).




created: the member had no own residential address; one is created, and LH Membership gives it to every club they are a member of (2.112.0).



replaced: the address differs; the old row is ended and kept, and clubs the member still belongs to move to the new one.



unchanged: nothing is written.



ended: every part is empty; the own-book residential use is ended, so the member has no current address. Clubs keep what they were given (Peter, 22 Nov 2026).




Writers, each storing all the parts of one save together: LH Profile Page&#8217;s field saver (3.22.0; profile forms, admin forms, check-ins, CRM, update-user-profile) and fill-fields (3.23.0; create-or-fill-user), LH Mysideline&#8217;s CSV import (1.6.0) and LH Multisite Importer (1.0.2). All three plugins require LH Addresses and have had no direct-meta fallbacks since stage 4 (LH Profile Page 3.26.0, LH Mysideline 1.7.0, LH Multisite Importer 1.1.0). No other code on the network writes the keys.



Reading through LH Addresses



Three readers, each taking an LH Profile Page address meta key and answering from the member&#8217;s current own residential address. Each returns null when the key is not an address key or the tables are not at their current schema. LH Profile Page then reads usermeta after get_meta_value() and own_residential_subquery(), because those code paths also serve non-address keys (gender, birthdate). search-users treats a null from find_user_ids() as no matches (since 3.26.1).




get_meta_value( $user_id, $meta_key ) (0.8.0): the value, in place of get_user_meta(). Street, town, postcode and state as stored (the state as a subdivision code such as VIC where it was mapped), the country as its English name (country_name()); &#8221; when the member has no address. Rows are cached per request; the cache is emptied on lh_addresses_saved, _replaced, _use_added and _use_ended.



find_user_ids( $meta_key, $values, $match ) (0.9.0): user IDs matching any of the values, in place of a meta query. partial uses LIKE, exact uses =. A country also matches by its English name (Australia for AU) and a state by its subdivision name (Victoria for VIC), among the countries on file.



own_residential_subquery( $meta_key ) (0.10.0): SQL for a derived table of user_id and meta_value, one row per user, in place of a usermeta join. Values are as stored, so the state and country are codes.




Readers moved: LH Profile Page 3.24.0 to 3.26.1 (LH_Profile_Phone_Field::return_user_meta() and so the fill-if-empty checks, CRM, check-ins, reports and update-user-profile; the five address inputs, xProfile and the backend profile table; contact cards; search-users results and filters; Users Insights), and LH Mysideline 1.7.0 (the CSV import&#8217;s fill rule). LH Contacts 0.6.0 refreshes cards on this plugin&#8217;s actions, and LH Profile Page 3.26.2 stopped asking it to watch the address meta keys. fill-fields counts an address part as filled when set_user_parts() succeeds, with no meta readback.



Stray writes to the meta



added_user_meta, updated_user_meta and deleted_user_meta on any of the five keys note the user and the key. On shutdown each user&#8217;s written keys are read (a deleted key counts as &#8221;) and overlaid on their address in the tables with address_from_table(), with the same results as set_user_parts(). Keys that were not written are never read, since they are stale; before 0.11.0 all five keys were copied together, which would now roll the other parts back.



The first such write per user per request is recorded in the network option lh_addresses_legacy_meta_writes (count, first_at, last_at, and the last 20 with user, key, action and caller; filter lh_addresses_return_legacy_writes_kept). Every entry names code that still writes the meta directly. A quiet record for a while, with the checks in lh-tasks #155341, is the cue to ask Peter about deleting the meta.



Retired in 0.11.0



The full copy from the meta to the tables: sync_user() now changes nothing and returns skipped, so the backfill (complete, pass 3: 6,280 users) can no longer write. The lh-addresses/resync-users ability, which ran it on demand, is removed. Both would have copied stale meta over addresses changed since.
""" ;
  sioc:topic <https://lhero.org/?taxonomy=author&term=cap-1>, <https://lhero.org/?taxonomy=lh_object_key&term=lh-portfolio_doc_20261121t170000-lh-addresses-legacy-sync> .

<https://lhero.org/author/1/#account> rdfs:seeAlso <https://lhero.org/author/1/?feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=author&term=cap-1> rdfs:seeAlso <https://lhero.org/?taxonomy=author&term=cap-1&feed=lhrdf&format=turtle> .
<https://lhero.org/?taxonomy=lh_object_key&term=lh-portfolio_doc_20261121t170000-lh-addresses-legacy-sync> rdfs:seeAlso <https://lhero.org/?taxonomy=lh_object_key&term=lh-portfolio_doc_20261121t170000-lh-addresses-legacy-sync&feed=lhrdf&format=turtle> .
