Repository navigation
Commit 68fe99f
Harden the WP_VERSION cache against typos, hangs and concurrent runs
Three points from review, all on the caching added to the Behat runner:
* A non-numeric WP_CLI_TEST_WP_VERSION_CACHE_TTL made `[ "${ttl}" -ge 0 ]`
fail rather than evaluate, which skipped the age check entirely and left the
cached copy valid forever. A typo therefore turned the cache into one that
never refreshes. Validated up front now, with a warning and the default TTL.
* The fetch was unbounded, so an unreachable or unresponsive host held up the
whole run instead of falling back to the cached copy. Bounded with
--connect-timeout and --max-time, after which the existing stale-cache path
takes over.
* The cache was written by truncating the target in place, so a concurrent
runner could read it between the truncation and the end of the write and hand
partial JSON to jq. It now goes to a temporary file in the same directory and
is moved into place, which is atomic. The move keeps the file readable to
others, as the shared cache directory needs and the old redirect did.
Refs wp-cli/wp-cli#6161
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W7iMRSfmFda1bzp87UcYoM1 parent e844d35 commit 68fe99f
1 file changed
Lines changed: 38 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
111 | 119 | | |
112 | 120 | | |
113 | 121 | | |
| |||
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
132 | 166 | | |
133 | 167 | | |
134 | 168 | | |
| |||
140 | 174 | | |
141 | 175 | | |
142 | 176 | | |
143 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
144 | 180 | | |
145 | 181 | | |
146 | 182 | | |
147 | | - | |
148 | | - | |
| 183 | + | |
149 | 184 | | |
150 | 185 | | |
151 | 186 | | |
| |||
0 commit comments