Repository navigation
feat: plan 030 — custom workflow catalog: 6 triggers, new condition fields and groups, 4 actions - #37
Merged
Merged
Conversation
…and may-refire warning
…s, customer stats
…meta key suggestions
…tions, collation guard
…o the site's runner can't take it first
…earch lists under their fields, rule issues under their rule
…ton; clock hint, zone only while blank
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.
Summary
Shop owners can now build their own workflows from New Workflow, not only start from a template. This PR adds:
Every write action is guarded at run time, because runs execute as user 0.
Base:
developf747ff8. No schema change: the claims table keeps its column, and guest claim keys are hashed to fit it. One commit per checkpoint, plusfix:commits from review. Built in three runs: CP0–CP6, CP7–CP10, CP11–CP16.Checkpoints
MetaKeys::order_blocked(): Update order custom field refuses WooCommerce's internal keys,wp_*keys and_yaymatik_*keys, at save and at run time.key+changed. Old → new goes in a private order note.yaymatik_active_triggers, rewritten under a lock after each activate, deactivate, apply or delete. The Dispatcher listens only to triggers in it.Action::emits()and themay_refirewarning, which never blocks Activate.matches_any/all/none,is_any_of,in_last/not_in_last(hours, days),is_set/is_not_set.order.meta/customer.meta.CustomerStatscounts paid statuses only, takes refunds off, and works on both order stores.customer.paid_order_countkeeps its key.SearchSelect.{ match, rules }one level deep. Old configs come out byte-identical. An empty group gets its own message.refunddata (amount, reason,is_full, stateless).Trigger::claim_key(): the key isuser:<id>, or for a guestemail:+ sha256 of the email.MetaKeys::user_collides(): before writing, the step reads the rows the write could reach under the column's collation.suggestdraws a<datalist>.assignable_roles()leaves out staff roles and roles with a protected capability.user_can()grants a protected capability.yaymatik_change_role_allow_alllifts the protections, except the last-role rule.yaymatik_resendable_emails. Skipped when the email is off or the order has no billing email.next_time()steps by calendar day inwp_timezone(), so DST is safe. Its time input came later, below.StepResult::wait()takes outputs, so later steps can readuntil.PersonSubjects::for_email()is moved out ofPersonalData, which now uses it too. The action itself is dropped below.check-catalog-e2e.phpruns one custom workflow per new trigger (group condition → customer email) and one run through all the new actions. Docs read-through; decisions CT gets its Cost block.Cancellation::for_subjects(),WorkflowStore::names()and thepowericon.PersonSubjectsstays for the personal data tools;RunStore::waiting_ids_for_subjects()stays for cart cancels, without its workflow filter.time('HH:MM', 00:00–23:59) replaceshour. PHP keeps it as a text field with a help line; the step's own form draws it as a native time input (step 60) in a 160px kitInputGroupwhose Clock button opens the browser's picker (showPicker(), the native icon hidden), next to the Days list. The store-time hint has a Clock icon and reads only "Store time (zone)." while the time is blank. The card and the hint show it in the site's time format (gmdateI18n).WaitUntil::validate()and the TS schema check the format with one message, "Enter a time, e.g. 9:15 am."next_time()takes hour and minute; tests for odd minutes, in a DST gap, in the repeated hour and past today's time. No migration: a storedhourconfig reads as a setup issue in PHP and on the card (checked incheck-catalog).Worth a closer look
MetaKeys::user_collides()(per user, no DISTINCT, a failed read refuses),ChangeCustomerRole::user_protected()/role_protected(), andUpdateCustomerMeta, which slashes its key and value so the stored key is the one checked.WorkflowStore::refresh_active_triggers()): readers store withINSERT IGNORE, and writers rewrite under one lock.check-catalogsimulates two interleaved writers from a second process.OrderPaidTrigger). WooCommerce fireswoocommerce_new_orderfor drafts too, so the order is caught around its first save, not at that hook.scope.trigger.claim_key.PROTECTED_CAPSallows customer rights only. On top of D8's staff and site capabilities:edit_posts,publish_posts,edit_others_posts,edit_pages,upload_files,moderate_comments,edit_products,edit_shop_coupons,manage_product_terms,view_woocommerce_reports,import,export. Triggers fire on public events, so any buyer would get the role, and customer roles only needread. Author, Editor and Contributor aren't assignable.docs/workflow-core-decisions.md, section CT.Before merging
chk… Men & Boys, left by earlier abortedcheck-catalogruns, can be deleted.Team after pulling develop
composer dump-autoload, then load wp-admin. No DB change.trigger_claims:wp db query "DROP TABLE IF EXISTS $(wp db prefix)yaymatik_trigger_claims",wp option delete yaymatik_db_version, then load wp-admin.How to test
./run.sh check-catalogchecks HPOS and the posts store, the second through its own process. It stops if the site has an active workflow on these triggers, so deactivate those first.check-winback,check-lifecycle,check-carts,check-runs,check-orders,check-storage,check-late-module, andcheck-status-flow <two order ids>.wp_capabilitiesshows an issue.