PluginProbe
404 Solution / 4.2.0
404 Solution v4.2.0
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / MutationWatermarkSeam.php

MutationWatermarkSeam.php in 404 Solution 4.2.0, at includes/MutationWatermarkSeam.php

274 lines 14.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 /**
8 * Source-mutation seam wrapping ABJ_404_Solution_MutationWatermark::bump().
9 *
10 * Every admin / REST / CLI / AJAX mutation that changes the redirects (or
11 * logs) source data calls $this->dao->bumpMutationWatermark() so the
12 * staged-build runner sees a higher counter than active_build_started_
13 * watermark at the next stage boundary and aborts cleanly. This is the
14 * single seam external callers reach into; the bump primitive itself
15 * lives on the static ABJ_404_Solution_MutationWatermark class
16 * (includes/MutationWatermark.php) so its atomic-INSERT contract stays
17 * decoupled from the DAO's connection-aware retry harness.
18 *
19 * Phase 3 Cluster A (queue t_260516_131217_769) wires the 14 admin call
20 * sites in PluginLogicTrait_AdminActions.php to this seam, paired with
21 * the existing markViewDoneInvalidatedByAdminMutation() admin-visibility
22 * seam. Phase 4 (queue c570) rewrites markViewDoneInvalidatedByAdmin
23 * Mutation() to record mutation_watermark_observed_by_admin_action
24 * against the watermark value rather than the unix-timestamp gate; until
25 * then both signals fire and the admin-visibility contract stays pinned
26 * by PostMutationViewDoneVisibilityTest.
27 *
28 * Why route through the DAO instead of calling the static method
29 * directly. Unit-test DAO stubs (the anonymous classes in
30 * AdminRedirectFormValidationTest, RegexAutoPromoteAdminSaveTest, and
31 * siblings) don't initialize a real $wpdb; the static bump() would
32 * fatal on its INSERT. The DAO seam lets every such stub provide a
33 * one-line no-op override, mirroring the existing markViewDone
34 * InvalidatedByAdminMutation stub pattern. The integration suite
35 * (LocalMariaDBServer-backed AdminMutationEndToEndCharacterizationTest)
36 * keeps the real bump in scope via the inherited DataAccess class.
37 *
38 * Lives in its own tiny trait, not on DataAccessTrait_ViewQueriesStaged,
39 * so the staged-queries trait stays under the 1500-line ModularityTest
40 * cap; the seam is conceptually the source-mutation counterpart to
41 * DataAccessTrait_ViewBuildForceRestart.php (runner-owned) so a parallel
42 * dedicated file is the right shape.
43 *
44 * @see docs/refactor-staged-view-build-watermark.md Phase 3.
45 * @see includes/MutationWatermark.php for the atomic-INSERT body.
46 *
47 * @property ABJ_404_Solution_DatabaseCore $dbCore
48 * @property ABJ_404_Solution_Functions $f
49 * @property ABJ_404_Solution_Logging $logger
50 * @property ABJ_404_Solution_ViewReadService|null $viewReadService
51 * @property ABJ_404_Solution_LogsRepository|null $logsRepo
52 * @property int $stagedQueryTimeoutSeconds
53 * @property string $lastBatchProgressDetail
54 * @property bool $viewBuildStageOpenForShutdown
55 * @property int $viewBuildShutdownStageNumber
56 * @property string $viewBuildShutdownStageKey
57 * @property bool|null $namedLockSupportedThisRequest
58 * @property bool $fallbackLockLoggedThisRequest
59 * @property bool $usingTransientFallbackLock
60 * @property string $lastNamedLockUnsupportedReason
61 * @property string $lastNamedLockUnsupportedError
62 * @method void abortStagedBuildForMutationWatermarkAdvance(...$arguments)
63 * @method bool acquireTransientFallbackLock(...$arguments)
64 * @method bool acquireViewBuildLock(...$arguments)
65 * @method string activeBuildStartedWatermarkOptionName(...$arguments)
66 * @method bool adminMutationGateBlocks(...$arguments)
67 * @method array<mixed> advanceViewBuildOnce(...$arguments)
68 * @method void assertBuildBufferExistsOrHalt(...$arguments)
69 * @method ?bool attemptRelaxSqlModeForBuildConnection(...$arguments)
70 * @method bool bufferIntegrityPassesForPromote(...$arguments)
71 * @method string buildHaltTransientKey(...$arguments)
72 * @method string buildViewDoneCountQuery(...$arguments)
73 * @method string builtWatermarkOptionName(...$arguments)
74 * @method int bumpMutationWatermark(...$arguments)
75 * @method int bumpStageNoProgressStreak(...$arguments)
76 * @method string capturedPrefixForLog(...$arguments)
77 * @method void capturePrefixAtBuildStart(...$arguments)
78 * @method void claimForegroundViewBuildLease(...$arguments)
79 * @method string classifyAndHandleStageFailure(...$arguments)
80 * @method array<mixed> classifySessionVariableWarnings(...$arguments)
81 * @method string classifyStageFailure(...$arguments)
82 * @method void clearActiveBuildStartedWatermark(...$arguments)
83 * @method void clearAdminMutationGateOptions(...$arguments)
84 * @method void clearAllProgressOptions(...$arguments)
85 * @method void clearPhpEnvironmentProbeCache(...$arguments)
86 * @method void clearPrefixAtStageOne(...$arguments)
87 * @method void clearSessionVariablesProbeCache(...$arguments)
88 * @method void clearSqlModeProbeCache(...$arguments)
89 * @method void clearStagedBuildDegradedState(...$arguments)
90 * @method void clearViewBuildOpenStageForShutdown(...$arguments)
91 * @method void clearViewDoneHardStaleNotice(...$arguments)
92 * @method ABJ_404_Solution_Clock clock(...$arguments)
93 * @method int countLiveRedirects(...$arguments)
94 * @method int countViewBuildRows(...$arguments)
95 * @method string describeBuildProgressForNotice(...$arguments)
96 * @method string describeDegradedNotice(...$arguments)
97 * @method string describeStagedSqlFailure(...$arguments)
98 * @method array<mixed> detectAndAdjustSqlMode(...$arguments)
99 * @method float detectHostStagedQueryLimitSeconds(...$arguments)
100 * @method string doTableNameReplacements(...$arguments)
101 * @method void dropDeletemeTable(...$arguments)
102 * @method void dropTransientBuffersIfPresent(...$arguments)
103 * @method void dropTransientStagedTables(...$arguments)
104 * @method void ensureConnection(...$arguments)
105 * @method void ensureFallbackLockNoticeAndLog(...$arguments)
106 * @method int extendedTimeoutForKilledNonBatchedStage(...$arguments)
107 * @method array<mixed> fetchSessionVariablesRowOrEmpty(...$arguments)
108 * @method string filesystemEnvironmentProbeOptionName(...$arguments)
109 * @method bool forceRestartViewBuild(...$arguments)
110 * @method bool foregroundViewBuildLeaseActive(...$arguments)
111 * @method string formatPhpMemoryBytesHuman(...$arguments)
112 * @method bool gateAbortIfMutationWatermarkAdvanced(...$arguments)
113 * @method string getColumnCollationString(...$arguments)
114 * @method int getCronStuckHours(...$arguments)
115 * @method string getLowercasePrefix(...$arguments)
116 * @method array<string, mixed> getViewBuildProgress(...$arguments)
117 * @method array<mixed> getViewBuildProgressFingerprint(...$arguments)
118 * @method int getViewDoneBuiltAtTimestamp(...$arguments)
119 * @method bool haltIfPrefixChangedSinceStageOne(...$arguments)
120 * @method string humanBatchProgress(...$arguments)
121 * @method float intelligentStagedQueryTimeoutSeconds(...$arguments)
122 * @method void invalidateViewDoneServeableCache(...$arguments)
123 * @method bool isBuildHaltedForHostFailure(...$arguments)
124 * @method bool isCurrentStageOptionName(...$arguments)
125 * @method bool isNamedLockUnsupportedError(...$arguments)
126 * @method bool isResumableStagedKill(...$arguments)
127 * @method bool isStageMarkedSkipped(...$arguments)
128 * @method bool isTransientConnectionError(...$arguments)
129 * @method string lastBuildStartedWatermarkOptionName(...$arguments)
130 * @method string legacyStartedWatermarkOptionName(...$arguments)
131 * @method string localizeOrDefaultViewBuildNotice(...$arguments)
132 * @method bool logsHitsTableExists(...$arguments)
133 * @method void logTimedViewBuildStage(...$arguments)
134 * @method void logViewBuildProgressOptionWrite(...$arguments)
135 * @method void logViewBuildShutdownDiagnostics(...$arguments)
136 * @method void markBuildHaltedForHostFailure(...$arguments)
137 * @method void markBuildStage(...$arguments)
138 * @method void markStageSkippedForHostFailure(...$arguments)
139 * @method void markViewBuildStageCompleted(...$arguments)
140 * @method void markViewBuildStageStarted(...$arguments)
141 * @method void markViewDoneBuildCompleted(...$arguments)
142 * @method void markViewDoneInvalidatedByAdminMutation(...$arguments)
143 * @method int maxBuildBufferId(...$arguments)
144 * @method void maybeRaiseViewDoneHardStaleNotice(...$arguments)
145 * @method bool mutationWatermarkAdvancedSinceBuildStart(...$arguments)
146 * @method int mutationWatermarkObservedByAdminAction(...$arguments)
147 * @method int mutationWatermarkObservedByAdminActionAt(...$arguments)
148 * @method string mutationWatermarkObservedByAdminActionAtOptionName(...$arguments)
149 * @method string mutationWatermarkObservedByAdminActionOptionName(...$arguments)
150 * @method string normalizePathPrefix(...$arguments)
151 * @method bool optionReadBackMatches(...$arguments)
152 * @method int parsePhpMemoryLimitToBytes(...$arguments)
153 * @method bool pathFallsWithinAny(...$arguments)
154 * @method void performFreshStartCleanup(...$arguments)
155 * @method array<mixed> phpDisabledFunctionsList(...$arguments)
156 * @method string phpEnvironmentProbeOptionName(...$arguments)
157 * @method float phpTimeRemainingSeconds(...$arguments)
158 * @method string prefixAtStageOneOptionName(...$arguments)
159 * @method array<mixed> probeFilesystemEnvironmentForBuild(...$arguments)
160 * @method float probeFloatFromValues(...$arguments)
161 * @method int probeIntFromValues(...$arguments)
162 * @method int probeMemoryLimitForS9(...$arguments)
163 * @method array<mixed> probePhpEnvironmentForBuild(...$arguments)
164 * @method array<mixed> probeSessionVariablesAtS1Entry(...$arguments)
165 * @method bool probeSetTimeLimitAvailability(...$arguments)
166 * @method array<mixed> probeSqlModeForBuild(...$arguments)
167 * @method string probeStringFromValues(...$arguments)
168 * @method string progressOptionName(...$arguments)
169 * @method void publishBuiltWatermarkFromActiveBuildStartedWatermark(...$arguments)
170 * @method array<mixed> queryAndGetResults(...$arguments)
171 * @method int readActiveBuildStartedWatermark(...$arguments)
172 * @method array<int, array<string, mixed>> readFromViewDone(...$arguments)
173 * @method int readProgressOption(...$arguments)
174 * @method int readWatermarkOption(...$arguments)
175 * @method void rebuildViewDoneInBackground(...$arguments)
176 * @method bool reconcilePostStageElevenState(...$arguments)
177 * @method string reconcileStagedTablesAtRunnerStartup(...$arguments)
178 * @method int recordStageBatchKilled(...$arguments)
179 * @method void registerViewBuildShutdownDiagnostics(...$arguments)
180 * @method bool releaseAndReacquireBetweenStages(...$arguments)
181 * @method void releaseViewBuildLock(...$arguments)
182 * @method void resetStageNoProgressStreak(...$arguments)
183 * @method string resolveColumnCollationForStagedBuild(...$arguments)
184 * @method void runForceRestartCleanupInsideLock(...$arguments)
185 * @method bool runIdRangeBatchedUpdate(...$arguments)
186 * @method int runInsertBatch(...$arguments)
187 * @method mixed runNonBatchedStageWithKillStreakEscape(...$arguments)
188 * @method array{ran: bool, reason: string, progress: array<string, mixed>} runPageLoadFallbackAdvance(...$arguments)
189 * @method int runRedirectsForViewCountStaged(...$arguments)
190 * @method array<int, array<string, mixed>> runRedirectsForViewStaged(...$arguments)
191 * @method bool runS11SwapWithPreRenameWatermarkRecheck(...$arguments)
192 * @method bool runStagedBuildOnce(...$arguments)
193 * @method bool runStagedBuildStages6Through11(...$arguments)
194 * @method void runStagedSqlFile(...$arguments)
195 * @method void runStagedSqlFileTolerantOfDuplicateKey(...$arguments)
196 * @method mixed runTimedViewBuildStage(...$arguments)
197 * @method int safeCurrentMutationWatermark(...$arguments)
198 * @method string sanitizeUrlBeforeInsert(...$arguments)
199 * @method void scheduleViewDoneRebuild(...$arguments)
200 * @method string sessionVariablesProbeOptionName(...$arguments)
201 * @method void setFilesystemEnvAdminNotice(...$arguments)
202 * @method void setLowMemoryLimitAdminNotice(...$arguments)
203 * @method void setSessionEnvAdminNotice(...$arguments)
204 * @method void setStagedBuildDegradedNotice(...$arguments)
205 * @method void setStagedBuildHaltNotice(...$arguments)
206 * @method void setViewBuildCronStuckNotice(...$arguments)
207 * @method void setViewBuildScheduleFailedNotice(...$arguments)
208 * @method void setViewDoneHardStaleNotice(...$arguments)
209 * @method array<mixed> splitOpenBasedirPaths(...$arguments)
210 * @method string sqlModeProbeOptionName(...$arguments)
211 * @method void stageAddPreJoinIndexes(...$arguments)
212 * @method void stageAddSortIndexes(...$arguments)
213 * @method void stageCreateBuildTable(...$arguments)
214 * @method array<string, mixed> stagedQueryOptions(...$arguments)
215 * @method bool stagedTableExists(...$arguments)
216 * @method bool stageInsertRedirectsBatched(...$arguments)
217 * @method string stageNoProgressStreakOptionName(...$arguments)
218 * @method void stageRenameSwap(...$arguments)
219 * @method string stageSkipOptionName(...$arguments)
220 * @method void stageUpdateExternal(...$arguments)
221 * @method void stageUpdateHits(...$arguments)
222 * @method void stageUpdateHome(...$arguments)
223 * @method bool stageUpdatePostsBatched(...$arguments)
224 * @method void stageUpdateSpecial(...$arguments)
225 * @method bool stageUpdateTermsBatched(...$arguments)
226 * @method void stampStartedWatermarksAtS1Entry(...$arguments)
227 * @method void sweepStaleRebuildTransients(...$arguments)
228 * @method string transientFallbackLockOptionName(...$arguments)
229 * @method bool verifyBuildLockSerializesWriter(...$arguments)
230 * @method bool verifyOptionWriteCoherent(...$arguments)
231 * @method bool verifyPrefixUnchangedSinceStageOne(...$arguments)
232 * @method int viewBuildBatchSize(...$arguments)
233 * @method int viewBuildBatchSizeForStage(...$arguments)
234 * @method array<mixed> viewBuildOnlyTranslations(...$arguments)
235 * @method float viewBuildPerStageBudgetSeconds(...$arguments)
236 * @method string viewBuildTableName(...$arguments)
237 * @method string viewDeletemeTableName(...$arguments)
238 * @method int viewDoneBuiltAt(...$arguments)
239 * @method int viewDoneBuiltWatermark(...$arguments)
240 * @method int viewDoneDataBuiltAt(...$arguments)
241 * @method string viewDoneDataBuiltAtOptionName(...$arguments)
242 * @method string viewDoneFreshnessOptionName(...$arguments)
243 * @method bool viewDoneHasRows(...$arguments)
244 * @method bool viewDoneIsFresh(...$arguments)
245 * @method bool viewDoneIsServeable(...$arguments)
246 * @method int viewDoneMutationInvalidatedAt(...$arguments)
247 * @method string viewDoneMutationInvalidatedAtOptionName(...$arguments)
248 * @method bool viewDoneTableExists(...$arguments)
249 * @method string viewDoneTableName(...$arguments)
250 * @method void writeProgressOption(...$arguments)
251 * @method void writeWatermarkOption(...$arguments)
252 */
253 class ABJ_404_Solution_MutationWatermarkSeam extends ABJ_404_Solution_ViewBuildCollaborator {
254
255 /**
256 * Bump the per-blog mutation watermark to signal "source redirect /
257 * logs data changed". Returns the post-increment counter value (the
258 * caller's own contribution, surfaced via $wpdb->insert_id per the
259 * LAST_INSERT_ID(expr) trick in MutationWatermark::bump()), or 0
260 * when the watermark class is not yet loaded (defensive guard for
261 * cold-bootstrap paths that could hit this seam before the
262 * autoloader has resolved MutationWatermark.php).
263 *
264 * @return int Post-increment counter value, or 0 if the primitive
265 * is unavailable.
266 */
267 public function bumpMutationWatermark(): int {
268 if (!class_exists('ABJ_404_Solution_MutationWatermark')) {
269 return 0;
270 }
271 return ABJ_404_Solution_MutationWatermark::bump();
272 }
273 }
274