<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MEG Venture &amp; Consulting Ltd.</title>
    <description>The latest articles on DEV Community by MEG Venture &amp; Consulting Ltd. (@megventure).</description>
    <link>https://dev.to/megventure</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4092984%2F016c214b-f326-47cf-a38a-b6901a0055cd.png</url>
      <title>DEV Community: MEG Venture &amp; Consulting Ltd.</title>
      <link>https://dev.to/megventure</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/megventure"/>
    <language>en</language>
    <item>
      <title>set_time_limit(0) does not save your long-running script from PHP-FPM</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Tue, 01 Dec 2026 07:04:46 +0000</pubDate>
      <link>https://dev.to/megventure/settimelimit0-does-not-save-your-long-running-script-from-php-fpm-ipp</link>
      <guid>https://dev.to/megventure/settimelimit0-does-not-save-your-long-running-script-from-php-fpm-ipp</guid>
      <description>&lt;p&gt;An import script that processes a few thousand rows starts with the traditional incantation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;set_time_limit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;ini_set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'memory_limit'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'512M'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It runs fine locally. On the server it dies partway through — no PHP fatal error, no entry in the PHP error log, sometimes a 502 or 504 in the browser, sometimes a truncated response. Raising the limit changes nothing, because the limit you raised is not the one doing the killing.&lt;/p&gt;

&lt;p&gt;There are at least three independent clocks on a request, owned by three different processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clock 1: PHP's own execution limit
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;max_execution_time&lt;/code&gt;, which &lt;code&gt;set_time_limit()&lt;/code&gt; sets at runtime.&lt;/p&gt;

&lt;p&gt;The manual is precise about what it measures, and it is not what most people assume:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;set_time_limit()&lt;/code&gt; function and the configuration directive &lt;code&gt;max_execution_time&lt;/code&gt; only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using &lt;code&gt;system()&lt;/code&gt;, stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. &lt;strong&gt;This is not true on Windows where the measured time is real.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So on Linux this clock does not tick while you are waiting on MySQL, reading a file, or calling an API. An import that spends 95% of its wall-clock time in database round-trips can run for ten minutes and register barely any "execution time" at all.&lt;/p&gt;

&lt;p&gt;That is why the symptom is confusing in both directions: scripts that should hit the limit do not, and scripts that are nowhere near it die anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clock 2: PHP-FPM's request timeout
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;request_terminate_timeout&lt;/code&gt;, set per pool in the FPM config. From the manual:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The timeout for serving a single request after which the worker process will be killed. &lt;strong&gt;This option should be used when the 'max_execution_time' ini option does not stop script execution for some reason.&lt;/strong&gt; A value of '0' means 'Off'.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Read that middle sentence again. It exists &lt;em&gt;precisely&lt;/em&gt; to override the case where &lt;code&gt;max_execution_time&lt;/code&gt; will not stop a script — which includes the case where the script asked for no limit at all.&lt;/p&gt;

&lt;p&gt;Two things follow:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It is wall-clock, and it is enforced by the FPM master&lt;/strong&gt;, not by your process. Your script has no say. &lt;code&gt;set_time_limit(0)&lt;/code&gt; is a request you make of the PHP engine; &lt;code&gt;request_terminate_timeout&lt;/code&gt; is a decision made about you by the process manager.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The kill is a &lt;code&gt;SIGTERM&lt;/code&gt; to the worker.&lt;/strong&gt; No PHP fatal error, no shutdown functions in the normal case, nothing in the PHP error log. What you get is in the FPM log, along the lines of &lt;code&gt;execution timed out (31.05 sec), terminating&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The default is &lt;code&gt;0&lt;/code&gt; — off. So this is not something PHP does to you out of the box; it is something your host does, and shared hosts and managed platforms very often do it. If you do not control the FPM pool config, you cannot raise it.&lt;/p&gt;

&lt;p&gt;Since PHP 7.3 there is also &lt;code&gt;request_terminate_timeout_track_finished&lt;/code&gt;, which extends the same watchdog over work done after &lt;code&gt;fastcgi_finish_request()&lt;/code&gt; — worth knowing if your plan was to close the connection and keep working.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clock 3: the web server in front
&lt;/h2&gt;

&lt;p&gt;nginx has &lt;code&gt;fastcgi_read_timeout&lt;/code&gt; (default 60s). Apache with mod_proxy_fcgi has &lt;code&gt;ProxyTimeout&lt;/code&gt;; with mod_fcgid, &lt;code&gt;FcgidIOTimeout&lt;/code&gt;. When this one fires first, nginx gives up on the response and returns &lt;strong&gt;504 Gateway Time-out&lt;/strong&gt; — while your PHP script is still happily running, because nothing told it to stop. You then get a half-finished import and a browser error, which is the worst of both.&lt;/p&gt;

&lt;p&gt;Cloudflare adds a fourth on the public path (524 after 100 seconds on the free plan), which is why "it works from the office VPN but not from outside" is a real report.&lt;/p&gt;

&lt;h2&gt;
  
  
  The diagnosis, in order
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Is there a PHP fatal error in the PHP error log?&lt;/strong&gt; &lt;code&gt;Maximum execution time of N seconds exceeded&lt;/code&gt; means clock 1 — this one you can raise.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Nothing in the PHP log, but the worker died?&lt;/strong&gt; Check the FPM log for &lt;code&gt;execution timed out ... terminating&lt;/code&gt;. That is clock 2.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;502/504 from the web server while the work appears to keep going?&lt;/strong&gt; Clock 3.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enable &lt;code&gt;request_slowlog_timeout&lt;/code&gt;&lt;/strong&gt; in the pool and read &lt;code&gt;slowlog&lt;/code&gt;. It dumps a PHP backtrace of what the request was doing when it went past the threshold, which is the single most useful thing available here and almost nobody turns it on.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The actual fix
&lt;/h2&gt;

&lt;p&gt;Stop trying to make one HTTP request last longer. You are arguing with three different owners, one of whom you do not control, and even if you win the request is still hostage to the visitor's browser and any proxy in between.&lt;/p&gt;

&lt;p&gt;Batch it instead. The shape:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process a fixed number of items per request — small enough that the slowest plausible batch finishes well inside the tightest timeout. We use 200 rows as a default for import work, which comfortably fits a 30-second budget.&lt;/li&gt;
&lt;li&gt;Record progress durably: a cursor, a "last processed id", a status row.&lt;/li&gt;
&lt;li&gt;Return, and have the client come back for the next batch. A button the admin presses again, a &lt;code&gt;&amp;lt;meta refresh&amp;gt;&lt;/code&gt;, a fetch loop in the admin page, or a cron job that takes one batch per run.&lt;/li&gt;
&lt;li&gt;Make the operation &lt;strong&gt;idempotent and resumable&lt;/strong&gt;, because it will be interrupted eventually — a deploy, a restart, a closed laptop.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pleasant side effect is that the merchant gets a progress indicator instead of a spinner, and an interruption costs one batch rather than the whole job.&lt;/p&gt;

&lt;p&gt;If the work genuinely must be one long-running unit — a migration, a full reindex — take it off the web entirely and run it from CLI. The CLI SAPI has &lt;code&gt;max_execution_time = 0&lt;/code&gt; by default and there is no FPM and no web server in the path. That is not a workaround; it is what CLI is for.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one-line version
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;set_time_limit(0)&lt;/code&gt; disables PHP's limit, which on Linux was not counting your database time anyway, and has no authority over the process manager that is actually going to kill you. If you cannot change the FPM pool config, the only real answer is to stop needing a long request.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;From maintaining around sixty PrestaShop modules at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;, where "the import stops halfway on my host" is a recurring ticket with the same three causes.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>devops</category>
      <category>nginx</category>
      <category>webdev</category>
    </item>
    <item>
      <title>isset($obj-&gt;id) is false and is_array($obj) is false — the object that is neither</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Wed, 11 Nov 2026 07:10:36 +0000</pubDate>
      <link>https://dev.to/megventure/issetobj-id-is-false-and-isarrayobj-is-false-the-object-that-is-neither-4d42</link>
      <guid>https://dev.to/megventure/issetobj-id-is-false-and-isarrayobj-is-false-the-object-that-is-neither-4d42</guid>
      <description>&lt;p&gt;Here is a resolver that looks defensive and correct:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;extractProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;is_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;is_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id_product'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id_product'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Object shape, array shape, safe fallback. It handles everything a template might hand you.&lt;/p&gt;

&lt;p&gt;Except it does not, and the way it fails is invisible.&lt;/p&gt;

&lt;h2&gt;
  
  
  The object that is neither
&lt;/h2&gt;

&lt;p&gt;PrestaShop 8 and 9 pass products to display hooks as a &lt;code&gt;ProductLazyArray&lt;/code&gt;, which extends &lt;code&gt;AbstractLazyArray&lt;/code&gt;. That class:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;implements &lt;code&gt;ArrayAccess&lt;/code&gt;, so &lt;code&gt;$product['id_product']&lt;/code&gt; works;&lt;/li&gt;
&lt;li&gt;does &lt;strong&gt;not&lt;/strong&gt; declare &lt;code&gt;__get()&lt;/code&gt; or &lt;code&gt;__isset()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Work through the resolver with one of those:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;is_object($product)&lt;/code&gt; → &lt;strong&gt;true&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;isset($product-&amp;gt;id)&lt;/code&gt; → &lt;strong&gt;false&lt;/strong&gt;. There is no real &lt;code&gt;id&lt;/code&gt; property and no &lt;code&gt;__isset()&lt;/code&gt; to consult, so PHP answers honestly: not set.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;is_array($product)&lt;/code&gt; → &lt;strong&gt;false&lt;/strong&gt;. &lt;code&gt;ArrayAccess&lt;/code&gt; makes the bracket syntax work; it does not make the value an array. &lt;code&gt;is_array()&lt;/code&gt; tests the actual type.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both branches decline. The function returns &lt;code&gt;0&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why you get no error
&lt;/h2&gt;

&lt;p&gt;Because &lt;code&gt;0&lt;/code&gt; is a perfectly good value to return, and every caller treats it as "no product here":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;hookDisplayProductAdditionalInfo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$params&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;extractProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'product'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c1"&gt;// &amp;lt;- every hook, every page&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An empty string from a display hook is indistinguishable from a hook that had nothing to say. So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;no exception,&lt;/li&gt;
&lt;li&gt;no log entry,&lt;/li&gt;
&lt;li&gt;no PHP notice — &lt;code&gt;isset()&lt;/code&gt; is specifically the function that does &lt;em&gt;not&lt;/em&gt; warn,&lt;/li&gt;
&lt;li&gt;the page renders perfectly, minus your block.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We shipped a product-reviews feature this way. Enabled, configured, correct, and rendering nowhere. The star ratings, the review list, the summary — all gone, on every product page, with the module reporting itself healthy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;Read through &lt;code&gt;ArrayAccess&lt;/code&gt; first, and check &lt;code&gt;offsetExists&lt;/code&gt; rather than property access:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;extractProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Scalar id passed directly.&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;is_numeric&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// ArrayAccess FIRST: covers ProductLazyArray and plain arrays alike.&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nc"&gt;ArrayAccess&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nf"&gt;is_array&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id_product'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// A real Product object.&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;is_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a fallback that costs nothing, because the URL dispatcher always knows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;Tools&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;getValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'id_product'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That last line is not laziness. A theme can call a hook from a context where the product variable is a summary array with a different key set, and the request parameter is the one thing that is reliably correct on a product page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four shapes, one test
&lt;/h2&gt;

&lt;p&gt;A theme can hand a hook a product in at least four forms, depending on the PrestaShop version and how the template was written:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;a &lt;code&gt;Product&lt;/code&gt; object,&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;ProductLazyArray&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;a plain array from &lt;code&gt;getTemplateVarProduct()&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;an integer id.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once you know that, the regression test writes itself, and it needs no PrestaShop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FakeLazyArray&lt;/span&gt; &lt;span class="k"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;ArrayAccess&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;offsetExists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;isset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;#[\ReturnTypeWillChange]&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;offsetGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;offsetSet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$v&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;offsetUnset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;unset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;$o&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;extractProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FakeLazyArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id_product'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'lazy array'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;extractProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id_product'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                    &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'plain array'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;extractProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;object&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                   &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'object'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;extractProductId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                                      &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'scalar'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Twelve lines of fake, four assertions, no framework. The fake is the important half: it reproduces the exact property that broke us — bracket access works, property access does not — which the real class would also do, if you could load it without booting a shop.&lt;/p&gt;

&lt;h2&gt;
  
  
  The generalisation
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ArrayAccess&lt;/code&gt; gives you the &lt;em&gt;syntax&lt;/em&gt; of an array without the &lt;em&gt;type&lt;/em&gt; of an array, and a class can implement it without implementing the magic methods that make property access work. Any check of the form&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;is_object&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'foo'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;has a hole for exactly that class of object, and the hole is silent because &lt;code&gt;isset()&lt;/code&gt; never warns.&lt;/p&gt;

&lt;p&gt;If you are writing a resolver for "some shape of thing a caller might pass me":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;branch on capability, not on type&lt;/strong&gt; — &lt;code&gt;instanceof ArrayAccess&lt;/code&gt; before &lt;code&gt;is_array&lt;/code&gt;, both before property access;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;make "not found" loud&lt;/strong&gt; during development. A resolver that returns &lt;code&gt;0&lt;/code&gt; and callers that early-return on &lt;code&gt;0&lt;/code&gt; is a machine for hiding this. Even a temporary &lt;code&gt;PrestaShopLogger::addLog()&lt;/code&gt; on the fallback path would have saved us a week;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;write the fake.&lt;/strong&gt; You cannot test against the real lazy array without the framework, and the property that breaks you is trivial to reproduce.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Found while adding product reviews to a testimonials module at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;. The hooks were registered, the settings were on, and the feature was invisible on every product page in the catalogue.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>debugging</category>
      <category>oop</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Round late — a two-cent bug in a price per square metre</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Tue, 27 Oct 2026 07:23:05 +0000</pubDate>
      <link>https://dev.to/megventure/round-late-a-two-cent-bug-in-a-price-per-square-metre-24ib</link>
      <guid>https://dev.to/megventure/round-late-a-two-cent-bug-in-a-price-per-square-metre-24ib</guid>
      <description>&lt;p&gt;A customer orders 12.75 m² of flooring. The cart line says €318.75. The order summary says €318.69.&lt;/p&gt;

&lt;p&gt;Six cents. Nobody notices for months, and then someone does, and now you are explaining arithmetic to a merchant who reasonably wants to know which of your two numbers is the real one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug
&lt;/h2&gt;

&lt;p&gt;The module sells by dimension: the shopper enters a width and a height, the module works out an area and multiplies by a unit price. The tax-excluded unit price was being rounded to two decimals &lt;strong&gt;before&lt;/strong&gt; the multiplication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// wrong&lt;/span&gt;
&lt;span class="nv"&gt;$unit&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getPriceWithoutTax&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// 25.0000 -&amp;gt; 25.00, fine&lt;/span&gt;
&lt;span class="nv"&gt;$total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$unit&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;$area&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                              &lt;span class="c1"&gt;// but not always fine&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a clean unit price nothing happens. With a price that is not exactly representable in two decimals — which is normal the moment tax-inclusive pricing, a currency conversion or a specific-price rule is involved — the rounding error is multiplied by the quantity:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;true unit price   24.995000
rounded to 2dp    24.99          (-0.005)
× 12.75 m²        318.6225  vs  318.68625   -&amp;gt; 6.4 cents lost
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The larger the order, the larger the gap. On a 200 m² order it is a euro.&lt;/p&gt;

&lt;p&gt;The rule is the boring one everybody knows and half of us implement backwards: &lt;strong&gt;carry full precision through the arithmetic and round once, at the end, for display.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// right&lt;/span&gt;
&lt;span class="nv"&gt;$total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getPriceWithoutTax&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;$area&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why the cart hid it
&lt;/h2&gt;

&lt;p&gt;This is the part that made it survive so long. The cart line and the order summary did not compute the number the same way. One path used the rounded unit price, the other used a total the module had already transmitted. They agreed for every price that survives two-decimal rounding, which is most of them, and diverged only for the rest.&lt;/p&gt;

&lt;p&gt;So the bug was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;invisible in testing&lt;/strong&gt;, because test products have prices like 10.00;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;invisible in most orders&lt;/strong&gt;, for the same reason;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;visible to exactly the merchants whose catalogue has awkward prices&lt;/strong&gt;, who are also the merchants least able to explain it to their accountant.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A discrepancy that only appears with unusual data is worse than one that appears always. An always-bug gets found on day one. This kind waits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to look for it in your own code
&lt;/h2&gt;

&lt;p&gt;Search for a rounded value being assigned to a variable and then used in arithmetic. The name is the tell — &lt;code&gt;$unitPrice&lt;/code&gt;, &lt;code&gt;$rate&lt;/code&gt;, &lt;code&gt;$perItem&lt;/code&gt;, &lt;code&gt;$hourlyRate&lt;/code&gt; — anything singular that will later be multiplied.&lt;/p&gt;

&lt;p&gt;Some concrete places this hides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rounding for display and reusing the display value.&lt;/strong&gt; Formatting a price for the page and then feeding that same variable into a total.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storing a rounded intermediate.&lt;/strong&gt; A column with &lt;code&gt;DECIMAL(10,2)&lt;/code&gt; for something that is not a final amount. The database rounds for you, silently, and now the precision is gone for good.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rounding inside a loop.&lt;/strong&gt; Rounding each line and summing, versus summing and rounding. Both are defensible for invoices — many jurisdictions require per-line rounding — but you must pick one deliberately and apply it in both the cart and the order, or you get exactly our six cents.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last one is the nuance that keeps this from being a slogan. "Round late" is right for a single computation. For a document with many lines, what matters is that every place that computes the document rounds &lt;em&gt;the same way&lt;/em&gt;. Our bug was not that we rounded early in one place; it was that we rounded early in one place and late in another.&lt;/p&gt;

&lt;h2&gt;
  
  
  The test worth writing
&lt;/h2&gt;

&lt;p&gt;Fixing it is one line. Keeping it fixed is the interesting part, because the next person to touch this code will reasonably think a rounded unit price is a sensible thing to have.&lt;/p&gt;

&lt;p&gt;Our regression test asserts both halves:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The fixed path: full precision, round once.&lt;/span&gt;
&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;priceFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;10.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;12.00&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;0.0001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'whole quantity'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;priceFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;10.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;2.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;30.00&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mf"&gt;0.0001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'fractional quantity'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// And the un-flagged legacy path STILL reproduces the old bug on purpose,&lt;/span&gt;
&lt;span class="c1"&gt;// so a future caller cannot silently drop the fix by omitting the flag.&lt;/span&gt;
&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;priceFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;10.00&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;2.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mf"&gt;30.00&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.0001&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'legacy path unchanged'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second assertion is the one people leave out. It documents that the old behaviour is still reachable and deliberately so, which means the day someone deletes the flag, a test fails and explains why instead of a merchant emailing you about six cents.&lt;/p&gt;

&lt;p&gt;The whole thing runs as plain PHP with no framework bootstrapped — the pricing function takes numbers and returns a number, which is the other half of making this testable at all. If your price calculation can only be exercised by building a cart, you will not write this test, and that is a design problem rather than a discipline problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Round once, at the end, for display.&lt;/li&gt;
&lt;li&gt;If a document has lines, decide &lt;em&gt;once&lt;/em&gt; how it rounds and make every code path that renders it agree.&lt;/li&gt;
&lt;li&gt;Prices like 10.00 in your fixtures will not catch this. Use 24.995.&lt;/li&gt;
&lt;li&gt;Assert the bug is still reproducible on the path you deliberately left alone.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;From a per-square-metre pricing module at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;. It took three releases to get right, mostly because each fix was correct and incomplete.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>testing</category>
      <category>ecommerce</category>
      <category>programming</category>
    </item>
    <item>
      <title>New writer, old reader — when your cache-buster doesn't bust the bundle</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Tue, 13 Oct 2026 12:05:05 +0000</pubDate>
      <link>https://dev.to/megventure/new-writer-old-reader-when-your-cache-buster-doesnt-bust-the-bundle-42a3</link>
      <guid>https://dev.to/megventure/new-writer-old-reader-when-your-cache-buster-doesnt-bust-the-bundle-42a3</guid>
      <description>&lt;p&gt;We shipped a release that renamed a JavaScript global. The PHP that &lt;em&gt;writes&lt;/em&gt; the global was updated. The JS that &lt;em&gt;reads&lt;/em&gt; it was updated. Both files were on the server. The feature did nothing.&lt;/p&gt;

&lt;p&gt;Page source showed the new global being written. The bundle being loaded still contained the old reader. New writer, old reader, no error, no console warning, no clue.&lt;/p&gt;

&lt;p&gt;This is a specific trap, but the shape is general enough to be worth knowing whatever framework you are in: &lt;strong&gt;an asset cache-buster only busts the cache it addresses.&lt;/strong&gt; If there is a second cache layer between you and the browser, and it is keyed on something you did not change, your version parameter is decorative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer one: the browser cache
&lt;/h2&gt;

&lt;p&gt;Register a front-end asset with no version and you get a plain tag with no query string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"modules/mymodule/views/js/upload.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Static assets on most hosts are served with far-future &lt;code&gt;Cache-Control&lt;/code&gt;. So after you fix a JS bug, sync files and clear the framework cache, &lt;strong&gt;returning visitors keep running the old file&lt;/strong&gt; until they hard-refresh. New visitors get the fix. That asymmetry is why a "still broken" report can be entirely browser cache, and why it is worth confirming before you debug anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;no-store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If that shows the new file, the deployed file is fine and you are looking at a cache problem, not a code problem.&lt;/p&gt;

&lt;p&gt;The fix in PrestaShop is a dedicated parameter, not a hand-built query string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$controller&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;registerJavascript&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s1"&gt;'modules-mymodule-upload'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'modules/'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/views/js/upload.js'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'position'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'bottom'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'priority'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'version'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;JavascriptManager::add()&lt;/code&gt; appends &lt;code&gt;?&amp;lt;version&amp;gt;&lt;/code&gt; &lt;strong&gt;after&lt;/strong&gt; it has resolved the path on disk.&lt;/p&gt;

&lt;h3&gt;
  
  
  The trap inside the fix
&lt;/h3&gt;

&lt;p&gt;Do &lt;strong&gt;not&lt;/strong&gt; put the query string in the path yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// broken&lt;/span&gt;
&lt;span class="nv"&gt;$controller&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;registerJavascript&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'modules/x/views/js/upload.js?v=2.1.0'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;AbstractAssetManager::getFullPath()&lt;/code&gt; runs &lt;code&gt;file_exists()&lt;/code&gt; on the raw relative path &lt;em&gt;before&lt;/em&gt; any version handling. &lt;code&gt;upload.js?v=2.1.0&lt;/code&gt; does not exist as a file, so the asset is &lt;strong&gt;never registered at all&lt;/strong&gt; — silently. No tag, no error.&lt;/p&gt;

&lt;p&gt;A related caution from a live test: &lt;code&gt;Media::getMediaPath()&lt;/code&gt;, used by the legacy &lt;code&gt;addJS()&lt;/code&gt;/&lt;code&gt;addCSS()&lt;/code&gt; path, does strip the query before its own &lt;code&gt;file_exists()&lt;/code&gt;, so reading the core source suggests a manual &lt;code&gt;?v=&lt;/code&gt; is safe there. On an actual PrestaShop 9.1.4 shop it was not: adding &lt;code&gt;?v=&amp;lt;version&amp;gt;&lt;/code&gt; to &lt;code&gt;addJS()&lt;/code&gt; inside a &lt;code&gt;hookDisplayHeader()&lt;/code&gt; made the browser stop requesting the file entirely — zero requests in the Network tab, while other output from the same hook rendered fine. We reverted it and never fully isolated the cause. The lesson is not about that one API; it is that &lt;strong&gt;a correct-looking static read of framework source is not a substitute for a live test on the target version.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Layer two: the combined bundle, which the version does not touch
&lt;/h2&gt;

&lt;p&gt;With &lt;code&gt;version&lt;/code&gt; in place we shipped the rename. It still did not work.&lt;/p&gt;

&lt;p&gt;PrestaShop's CCC ("combine, compress, cache") option concatenates all the page's JS into one bundle. &lt;code&gt;CccReducer::reduceJs()&lt;/code&gt; names that bundle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;position&amp;gt;-&amp;lt;sha1(joined file paths)&amp;gt;&amp;lt;PS_CCCJS_VERSION&amp;gt;.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read that carefully. The hash is over the &lt;strong&gt;file paths&lt;/strong&gt;, not the file contents. And &lt;code&gt;JavascriptManager::add()&lt;/code&gt; stores the version-less &lt;code&gt;$srcPath&lt;/code&gt; as the asset's &lt;code&gt;path&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;changing a file's &lt;strong&gt;contents&lt;/strong&gt; does not change the bundle name;&lt;/li&gt;
&lt;li&gt;changing the &lt;code&gt;version&lt;/code&gt; parameter does not change the bundle name either;&lt;/li&gt;
&lt;li&gt;the reducer checks &lt;code&gt;filesystem-&amp;gt;exists()&lt;/code&gt; on that name, finds the old bundle, and serves it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Forever. There is no expiry.&lt;/p&gt;

&lt;p&gt;Observed live: the page HTML emitted the new &lt;code&gt;csfNumOfAttachments&lt;/code&gt; global from the new PHP, while &lt;code&gt;bottom-3fc480223.js&lt;/code&gt; still contained the previous &lt;code&gt;contact-upload.js&lt;/code&gt; reading &lt;code&gt;window.numofattachments&lt;/code&gt;. Both files on disk were correct. The bundle in between was a fossil.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix that actually covers both layers
&lt;/h2&gt;

&lt;p&gt;When a release changes the &lt;strong&gt;content&lt;/strong&gt; of a front-end JS or CSS file, the upgrade script has to invalidate the bundle explicitly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;upgrade_module_1_3_0&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$module&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Clears themes/&amp;lt;theme&amp;gt;/assets/cache/* and bumps&lt;/span&gt;
    &lt;span class="c1"&gt;// PS_CCCJS_VERSION / PS_CCCCSS_VERSION.&lt;/span&gt;
    &lt;span class="nc"&gt;Media&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;clearCache&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need both:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;'version'&lt;/code&gt; handles the non-combined case (CCC off, or assets served individually).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Media::clearCache()&lt;/code&gt; handles the combined case.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Neither one covers the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this class of bug is expensive
&lt;/h2&gt;

&lt;p&gt;It does not look like a caching problem. It looks like your feature is broken. The writer and the reader are both correct in the repository, both correct on disk, and disagree only in the artefact the framework assembled between them. Every instinct says "read the code again", and the code is fine.&lt;/p&gt;

&lt;p&gt;Two habits that shorten it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;When a fix does not take effect, verify what is actually being served before re-reading your source.&lt;/strong&gt; Fetch the deployed asset with &lt;code&gt;cache: 'no-store'&lt;/code&gt;. Look at the bundle, not the file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Treat "rename a shared symbol" as a deployment problem, not just a code change.&lt;/strong&gt; Any rename that splits a writer from its reader across two files will fail this way if either side is stale. If you can, ship the change so the reader tolerates both names for one release. Then the fossil bundle is merely old, not broken.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Neither is exotic. Both are things we now do because the alternative cost us a release.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;From maintaining around sixty PrestaShop modules at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;. The specifics above are PrestaShop 1.7 through 9, but any framework with an asset pipeline that concatenates by path has the same hole.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webperf</category>
      <category>caching</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Cubicle v0.22: a wider office, approvals you can read, and four new agent feeds</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Mon, 12 Oct 2026 19:24:56 +0000</pubDate>
      <link>https://dev.to/megventure/cubicle-v022-a-wider-office-approvals-you-can-read-and-four-new-agent-feeds-c7n</link>
      <guid>https://dev.to/megventure/cubicle-v022-a-wider-office-approvals-you-can-read-and-four-new-agent-feeds-c7n</guid>
      <description>&lt;p&gt;Cubicle shows your AI agents as people in a pixel-art office: they walk to a desk when they start working, raise a hand when they need you, and go for coffee when they’re done. Last week’s post was about answering them from Telegram. Here’s what changed since.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The office grows sideways.&lt;/strong&gt; A big company on a wide screen used to stack more and more rows. Now the office opens extra desk wings so its shape follows the window; phones and tall windows still get rows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approvals you can read.&lt;/strong&gt; When a Paperclip agent asks the board to approve something, clicking its raised hand now shows the approval’s title, summary and risks, and the button opens Paperclip’s approval page directly. Telegram messages carry the same summary. Cubicle stays read-only: you decide in Paperclip.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fewer false alarms.&lt;/strong&gt; A failed run that was dealt with (agent paused and resumed, or a later run finished) no longer leaves “Last run failed” on the card. Telegram uses the same rule, and a “needs you” message is marked done only after it has been answered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More agents in the office,&lt;/strong&gt; thanks to contributions from Serkan Özcan: a read-only Codex Desktop/CLI observer, feed examples for GitHub Copilot, Antigravity and Grok CLI, a macOS LaunchAgent setup, and Telegram access controls (choose exactly which Telegram users can pair and get alerts).&lt;/p&gt;

&lt;p&gt;Try it: npx @caglarutkuguler/cubicle, or install it as a Paperclip plugin with npx paperclipai plugin install @caglarutkuguler/cubicle.&lt;br&gt;
Repo: &lt;a href="https://github.com/caglarutkuguler/cubicle" rel="noopener noreferrer"&gt;https://github.com/caglarutkuguler/cubicle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The open theme ideas (hospital, kitchen, classroom, newsroom) are still up for grabs. A theme is one file; docs/THEMES.md explains how to write one.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>opensource</category>
      <category>ai</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Cubicle v0.21: my AI-agent office now asks me things (and I can answer from Telegram)</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Mon, 05 Oct 2026 11:28:47 +0000</pubDate>
      <link>https://dev.to/megventure/cubicle-v021-my-ai-agent-office-now-asks-me-things-and-i-can-answer-from-telegram-265b</link>
      <guid>https://dev.to/megventure/cubicle-v021-my-ai-agent-office-now-asks-me-things-and-i-can-answer-from-telegram-265b</guid>
      <description>&lt;p&gt;A week ago Cubicle was a read-only pixel office for Paperclip agents (v0.7). Since then it went through 23 releases. The biggest changes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;More than Paperclip.&lt;/strong&gt; Claude Code, Codex CLI and Gemini CLI now feed the office through hooks, and each Claude Code subagent gets its own character (thanks @omeruyanik03).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agents' questions surface.&lt;/strong&gt; When an agent is waiting on you, the question shows on its card, in the side panel and on Telegram. Telegram sends one question at a time, and your reply goes back as a comment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Telegram setup without a terminal.&lt;/strong&gt; Link it by QR code or code from the page, choose alerts per chat (&lt;code&gt;/alerts&lt;/code&gt;, &lt;code&gt;/mute&lt;/code&gt;), and limit access to specific users (thanks &lt;a class="mentioned-user" href="https://dev.to/serkanozcan"&gt;@serkanozcan&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KPI board, replay mode, hand-off walks, five new HD themes&lt;/strong&gt;, and a layout that works on phones.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Still zero dependencies and still read-only toward your agents.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Four open theme issues (hospital, kitchen, classroom, newsroom) are tagged good first issue if you want to draw one.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx @caglarutkuguler/cubicle&lt;/code&gt; · &lt;a href="https://github.com/caglarutkuguler/cubicle" rel="noopener noreferrer"&gt;https://github.com/caglarutkuguler/cubicle&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>javascript</category>
      <category>showdev</category>
    </item>
    <item>
      <title>"Duplicate entry '0' for key PRIMARY" usually means your database lost AUTO_INCREMENT</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Tue, 29 Sep 2026 13:15:06 +0000</pubDate>
      <link>https://dev.to/megventure/duplicate-entry-0-for-key-primary-usually-means-your-database-lost-autoincrement-472f</link>
      <guid>https://dev.to/megventure/duplicate-entry-0-for-key-primary-usually-means-your-database-lost-autoincrement-472f</guid>
      <description>&lt;p&gt;Installing a plugin fails with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Duplicate entry '0' for key 'PRIMARY'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The obvious reading is that the plugin tried to insert a row with id 0. The actual reading is usually the opposite: the plugin inserted a row &lt;strong&gt;without&lt;/strong&gt; naming the id column, relied on &lt;code&gt;AUTO_INCREMENT&lt;/code&gt; to supply one, and got &lt;code&gt;0&lt;/code&gt; because the column no longer has &lt;code&gt;AUTO_INCREMENT&lt;/code&gt; on it. The second such insert then collides with the first.&lt;/p&gt;

&lt;p&gt;This is not a plugin bug, and chasing it as one wastes a lot of time. Here is how it looks, why it spreads, and how to repair it without setting a second trap.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tell: it moves
&lt;/h2&gt;

&lt;p&gt;We first saw this installing a module on a PrestaShop shop. The failure walked through the tables in order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;ps_configuration&lt;/code&gt; — first setting the module writes&lt;/li&gt;
&lt;li&gt;then &lt;code&gt;ps_log&lt;/code&gt; — the "starting module install" row&lt;/li&gt;
&lt;li&gt;then &lt;code&gt;ps_module&lt;/code&gt; — the row that registers the module itself&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Fix one table, run the install again, fail on the next. That whack-a-mole is the diagnostic. &lt;strong&gt;A plugin bug does not migrate to core tables.&lt;/strong&gt; If your failure changes table each time you fix one, the corruption is database-wide.&lt;/p&gt;

&lt;p&gt;Later the same shop failed in the storefront: adding anything to the cart threw the same error on &lt;code&gt;INSERT INTO ps_cart&lt;/code&gt;. Same cause, another table nobody had touched yet. If it had got as far as checkout it would have been &lt;code&gt;ps_orders&lt;/code&gt; next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where it comes from
&lt;/h2&gt;

&lt;p&gt;A bad import or restore. &lt;code&gt;mysqldump&lt;/code&gt;, phpMyAdmin exports and various migration tools can produce a schema that recreates the primary key &lt;strong&gt;without&lt;/strong&gt; the &lt;code&gt;AUTO_INCREMENT&lt;/code&gt; attribute — and such a restore often leaves the internal counters stale as well, with rows stranded at id 0.&lt;/p&gt;

&lt;p&gt;On the shop we repaired, &lt;em&gt;every&lt;/em&gt; &lt;code&gt;AUTO_INCREMENT&lt;/code&gt; in the database was gone: products, combinations, modules, configuration, employees, shops, languages, and around fifty-five module tables.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trap when you fix it
&lt;/h2&gt;

&lt;p&gt;The natural fix is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="nv"&gt;`ps_log`&lt;/span&gt; &lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="nv"&gt;`id_log`&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;UNSIGNED&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;which fails with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#1062 - ALTER TABLE causes auto_increment resequencing,
        resulting in duplicate entry 'N' for key 'PRIMARY'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding &lt;code&gt;AUTO_INCREMENT&lt;/code&gt; makes MySQL renumber the existing &lt;code&gt;id = 0&lt;/code&gt; row, and the stale counter hands it an id that is already in use.&lt;/p&gt;

&lt;p&gt;Prevent the renumber:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SET&lt;/span&gt; &lt;span class="k"&gt;SESSION&lt;/span&gt; &lt;span class="n"&gt;sql_mode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'NO_AUTO_VALUE_ON_ZERO'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="nv"&gt;`ps_log`&lt;/span&gt;           &lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="nv"&gt;`id_log`&lt;/span&gt;           &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;UNSIGNED&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="nv"&gt;`ps_configuration`&lt;/span&gt; &lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="nv"&gt;`id_configuration`&lt;/span&gt; &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;UNSIGNED&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="nv"&gt;`ps_module`&lt;/span&gt;        &lt;span class="k"&gt;MODIFY&lt;/span&gt; &lt;span class="nv"&gt;`id_module`&lt;/span&gt;        &lt;span class="nb"&gt;INT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;UNSIGNED&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt; &lt;span class="n"&gt;AUTO_INCREMENT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;NO_AUTO_VALUE_ON_ZERO&lt;/code&gt; tells MySQL to treat a literal &lt;code&gt;0&lt;/code&gt; as a real value rather than a request for the next id, so the existing row keeps its id and nothing is renumbered.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run the &lt;code&gt;SET&lt;/code&gt; and the &lt;code&gt;ALTER&lt;/code&gt;s in the same submission.&lt;/strong&gt; &lt;code&gt;SET SESSION&lt;/code&gt; lasts for one connection; phpMyAdmin may hand you a different connection for a separate query, and then the &lt;code&gt;ALTER&lt;/code&gt; fails exactly as before while you are certain you just set the mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding every affected table
&lt;/h2&gt;

&lt;p&gt;Do not do this by hand. Ask the schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="k"&gt;TABLE_NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;COLUMN_NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;COLUMN_TYPE&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;information_schema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;COLUMNS&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;TABLE_SCHEMA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'your_database_name'&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;COLUMN_KEY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'PRI'&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;EXTRA&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="k"&gt;LIKE&lt;/span&gt; &lt;span class="s1"&gt;'%auto_increment%'&lt;/span&gt;
  &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;DATA_TYPE&lt;/span&gt; &lt;span class="k"&gt;IN&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'int'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'bigint'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'smallint'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'mediumint'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'tinyint'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt; &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="k"&gt;TABLE_NAME&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Hardcode the schema name.&lt;/strong&gt; A generator built on &lt;code&gt;DATABASE()&lt;/code&gt; returns nothing when phpMyAdmin is sitting in the &lt;code&gt;information_schema&lt;/code&gt; context, which it often is if you arrived through the schema browser. The query runs, returns zero rows, and you conclude the database is fine.&lt;/p&gt;

&lt;p&gt;That query lists candidates. It does not list &lt;em&gt;fixes&lt;/em&gt; — and the difference matters, because some of those primary keys are legitimately not auto-increment.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to exclude
&lt;/h2&gt;

&lt;p&gt;Blindly ALTERing everything the query returns will damage your database. Exclude:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Every composite primary key.&lt;/strong&gt; &lt;code&gt;AUTO_INCREMENT&lt;/code&gt; applies to a single column that is the leftmost part of a key. Multi-column PKs in that list are joins and pivots and must be left alone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Single-column integer PKs that are by design not auto-increment&lt;/strong&gt; — a foreign key doubling as the primary key. In PrestaShop those include &lt;code&gt;ps_address_format&lt;/code&gt; (&lt;code&gt;id_country&lt;/code&gt;), &lt;code&gt;ps_product_sale&lt;/code&gt; (&lt;code&gt;id_product&lt;/code&gt;), &lt;code&gt;ps_ip2location&lt;/code&gt; (&lt;code&gt;ip_to&lt;/code&gt;), the &lt;code&gt;ps_layered_indexable_*&lt;/code&gt; tables, &lt;code&gt;ps_pscheckout_address&lt;/code&gt; / &lt;code&gt;ps_pscheckout_customer&lt;/code&gt; (&lt;code&gt;id_customer&lt;/code&gt;), &lt;code&gt;ps_psshipping_address&lt;/code&gt;, and the &lt;code&gt;ps_eventbus_*&lt;/code&gt; tables. Your schema will have its own equivalents: the test is whether the value is &lt;em&gt;assigned by another table&lt;/em&gt; or &lt;em&gt;generated here&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Two special cases worth knowing, because they look like exclusions and are not: &lt;code&gt;ps_customization.id_customization&lt;/code&gt; and &lt;code&gt;ps_cms_role.id_cms_role&lt;/code&gt; sit in composite primary keys but are legitimately &lt;code&gt;AUTO_INCREMENT&lt;/code&gt;, as the leftmost column.&lt;/p&gt;

&lt;p&gt;The workable process: generate the &lt;code&gt;ALTER&lt;/code&gt; statements with a query that CONCATs them, &lt;strong&gt;read the output&lt;/strong&gt;, delete the rows that belong to the exclusion list, then run what is left. Two failure modes we hit doing exactly this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running the generator and believing that fixed something. It only prints statements. You have to run its output.&lt;/li&gt;
&lt;li&gt;Deleting the &lt;code&gt;id = 0&lt;/code&gt; rows &lt;em&gt;instead of&lt;/em&gt; running the ALTERs. That clears the immediate collision and leaves the schema still broken, so it comes back on the next insert.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more operational detail: if you paste a large batch into phpMyAdmin and the newlines are lost, a &lt;code&gt;--&lt;/code&gt; comment swallows the statement that follows it. Ship comment-free SQL for bulk paste.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to do instead, if you can
&lt;/h2&gt;

&lt;p&gt;Repairing in place works — we did it across about 130 tables and verified the storefront afterwards — but think about what it means. A restore that dropped &lt;code&gt;AUTO_INCREMENT&lt;/code&gt; from every primary key was not selective. It may also have dropped foreign keys, defaults, or column attributes you have not noticed yet, and no amount of ALTERing primary keys tells you about those.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If a clean dump from before the bad import exists, restore that instead.&lt;/strong&gt; The in-place repair is what you do when it does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The five-second version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Plugin install fails on a core table with &lt;code&gt;Duplicate entry '0'&lt;/code&gt; → suspect the schema, not the plugin.&lt;/li&gt;
&lt;li&gt;Failure moves to a different table each time you fix one → confirmed, it is database-wide.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SET SESSION sql_mode = 'NO_AUTO_VALUE_ON_ZERO'&lt;/code&gt; in the same submission as the ALTERs.&lt;/li&gt;
&lt;li&gt;Drive it from &lt;code&gt;information_schema&lt;/code&gt;, hardcode the schema name, and curate the list before running it.&lt;/li&gt;
&lt;li&gt;Prefer restoring a good dump.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;From maintaining around sixty PrestaShop modules at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;. We lost a fortnight to this one in two separate incidents before recognising the shape.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mysql</category>
      <category>php</category>
      <category>database</category>
      <category>devops</category>
    </item>
    <item>
      <title>What your comments changed in my AI-agent office (Cubicle v0.7)</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Mon, 28 Sep 2026 18:09:08 +0000</pubDate>
      <link>https://dev.to/megventure/what-your-comments-changed-in-my-ai-agent-office-cubicle-v07-4265</link>
      <guid>https://dev.to/megventure/what-your-comments-changed-in-my-ai-agent-office-cubicle-v07-4265</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fekkn0c4nefyuiq389pkn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fekkn0c4nefyuiq389pkn.gif" alt="Cubicle: a live pixel-art office for AI agents"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yesterday I wrote about &lt;a href="https://dev.to/megventure/i-gave-my-ai-agents-an-office-and-made-it-read-only-on-purpose-5dpd"&gt;Cubicle&lt;/a&gt;, a live pixel-art office for AI agents that is read-only on purpose. A few of the comments were better code reviews than I get from most tools, so here's what they changed.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The hook was losing updates
&lt;/h2&gt;

&lt;p&gt;ContentClips pointed out that several Claude Code sessions fire hooks at the same moment, and every hook run rewrites the same &lt;code&gt;claude-code.json&lt;/code&gt;. I was already writing to a temp file and renaming it, so a reader never sees half a file. But that only solves torn reads, not lost updates: two runs can both read the file, both change it, and the second rename silently throws away the first one's change.&lt;/p&gt;

&lt;p&gt;I measured it before touching anything. 30 hook runs started at once, each registering a different session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sessions recorded: 20 of 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A third of the updates were gone. With subagents in the mix (more on that below), bursts like this are normal.&lt;/p&gt;

&lt;p&gt;The fix is a lock file created with &lt;code&gt;O_EXCL&lt;/code&gt; around the read-modify-write. The constraint that shaped it: this hook runs on every tool call, so it must never hold Claude up. It waits at most one second and then writes anyway, and a lock left behind by a crashed run is taken over after two seconds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;withLock&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deadline&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;LOCK_WAIT_MS&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;while &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;openSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LOCK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;wx&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;EEXIST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;statSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LOCK&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;mtimeMs&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;STALE_LOCK_MS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unlinkSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LOCK&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;deadline&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// write anyway rather than block Claude&lt;/span&gt;
    &lt;span class="nf"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fd&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;closeSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fd&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;unlinkSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;LOCK&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After: 40 of 40, three runs in a row, no lock file left behind. Both cases are in the test suite now.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The office was showing more than it should
&lt;/h2&gt;

&lt;p&gt;The same comment raised a second point: in kiosk mode the office ends up on a shared TV, and task titles or tool calls can contain things you don't want on a wall.&lt;/p&gt;

&lt;p&gt;When I looked, the problem was bigger than the bubbles. The proxy passed Paperclip's responses through unchanged. A single issue on my own instance had more than 70 fields: descriptions, workspace settings, run ids, monitor notes. The page uses about five of them. Read-only was never the same as minimal.&lt;/p&gt;

&lt;p&gt;Two changes in v0.7:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Always:&lt;/strong&gt; the server now forwards only the fields the page draws. Descriptions, adapter and workspace configuration, run ids and closed issues never leave the server.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--redact&lt;/code&gt;:&lt;/strong&gt; task titles, commands and error text are stripped on the server too. The office shows &lt;code&gt;MEG-35&lt;/code&gt;, &lt;code&gt;Edit&lt;/code&gt;, &lt;code&gt;allow Bash&lt;/code&gt; and statuses, and the "needs you" signal still works. Because it happens server-side, changing the page URL doesn't bring the details back, and neither does someone calling the API on that port directly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The test for it feeds in an AWS key, an SSH key path, an API key in adapter config and a bearer token inside a &lt;code&gt;curl&lt;/code&gt; command, then checks that none of them come out of any endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Observability hooks vs. enforcement hooks
&lt;/h2&gt;

&lt;p&gt;Hamid Ahmadian made a point I wish I'd written down myself: a hook that draws the office and a hook that blocks tool calls have opposite contracts. The first must never fail loudly; the second exists to fail loudly (exit 2). If one script does both, a bug in the drawing code can start blocking tool calls.&lt;/p&gt;

&lt;p&gt;Cubicle keeps to the first contract: it always exits 0, prints nothing, and &lt;code&gt;install-hooks&lt;/code&gt; adds its own separate entries next to whatever hooks you already have instead of merging into them. Reid Marlow's comment on ignoring the one-minute idle reminder was the same idea from the user's side: the office is only useful if the raised hands mean something.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. The first community PR
&lt;/h2&gt;

&lt;p&gt;A day after launch, &lt;a href="https://github.com/omeruyanik03" rel="noopener noreferrer"&gt;@omeruyanik03&lt;/a&gt; opened the first pull request. Claude Code subagents share their parent's session id, so a session that fans out to four subagents showed up as one character whose bubble flickered between five tool calls. The PR gives every subagent its own character, keyed on the &lt;code&gt;agent_id&lt;/code&gt; that Claude Code puts on hook events, with tests for the awkward cases: a subagent first seen halfway through its run, older Claude Code versions without &lt;code&gt;agent_id&lt;/code&gt;, and a session ending while its subagents are still at their desks.&lt;/p&gt;

&lt;p&gt;Because that hook runs on every tool call on my machine, I read it line by line before merging: no network, no child processes, no new dependencies, still exits 0 on every error. It shipped in v0.6.0 the same evening, and it's also why the lock in section 1 mattered so quickly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Paperclip and Claude Code in one office, details hidden for a shared screen&lt;/span&gt;
npx @caglarutkuguler/cubicle@latest install-hooks
npx @caglarutkuguler/cubicle@latest &lt;span class="nt"&gt;--source&lt;/span&gt; paperclip,claude-code &lt;span class="nt"&gt;--redact&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open &lt;code&gt;http://127.0.0.1:3200/?kiosk&lt;/code&gt;. Or try the &lt;a href="https://caglarutkuguler.github.io/cubicle/?lang=en" rel="noopener noreferrer"&gt;live demo&lt;/a&gt; without installing anything.&lt;/p&gt;

&lt;p&gt;Thanks to everyone who took the time to read the code and not just the post. The repo is &lt;a href="https://github.com/caglarutkuguler/cubicle" rel="noopener noreferrer"&gt;github.com/caglarutkuguler/cubicle&lt;/a&gt;, MIT licensed, and the open issues labelled &lt;code&gt;good first issue&lt;/code&gt; are a nice place to start.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
    <item>
      <title>I gave my AI agents an office (and made it read-only on purpose)</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Sun, 27 Sep 2026 20:44:36 +0000</pubDate>
      <link>https://dev.to/megventure/i-gave-my-ai-agents-an-office-and-made-it-read-only-on-purpose-5dpd</link>
      <guid>https://dev.to/megventure/i-gave-my-ai-agents-an-office-and-made-it-read-only-on-purpose-5dpd</guid>
      <description>&lt;p&gt;I run several AI agents at once: a handful of Claude Code sessions, plus a small "company" of agents on &lt;a href="https://github.com/paperclipai/paperclip" rel="noopener noreferrer"&gt;Paperclip&lt;/a&gt; that works on our online store. Giving them work is easy. The hard part is knowing, at a glance, which one is working, which one is done, and which one has been waiting for my answer for twenty minutes.&lt;/p&gt;

&lt;p&gt;Logs don't answer that at a glance. So I drew an office.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fekkn0c4nefyuiq389pkn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fekkn0c4nefyuiq389pkn.gif" alt="Cubicle demo" width="720" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://caglarutkuguler.github.io/cubicle/?lang=en" rel="noopener noreferrer"&gt;Live demo, no install&lt;/a&gt;&lt;/strong&gt; · &lt;a href="https://github.com/caglarutkuguler/cubicle" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; · &lt;code&gt;npx @caglarutkuguler/cubicle&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What the office shows
&lt;/h2&gt;

&lt;p&gt;Every agent is a character:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Working:&lt;/strong&gt; sits at its desk and types, with the current task or tool call above its head&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Needs you:&lt;/strong&gt; raises a hand, and the monitor turns amber&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Done:&lt;/strong&gt; says "✓ done" and walks to the lounge for a coffee&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error:&lt;/strong&gt; slumps at the desk, red screen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The header keeps a count of how many agents need you. That single number turned out to be the most useful thing on the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three design decisions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Zero dependencies
&lt;/h3&gt;

&lt;p&gt;The server is a single Node file of under 200 lines, using only the standard library: it serves one HTML page and proxies a few requests. The page draws everything with &lt;code&gt;fillRect&lt;/code&gt; on a 352×208 canvas. There are no image assets, no framework, and no build step.&lt;/p&gt;

&lt;p&gt;This wasn't minimalism for its own sake. A tool that sits next to your agents all day should be something you can read in ten minutes and trust.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Read-only by design
&lt;/h3&gt;

&lt;p&gt;Cubicle only ever makes &lt;code&gt;GET&lt;/code&gt; requests. In Paperclip mode it forwards exactly three endpoints and refuses everything else:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ALLOWED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;api&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;health$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;api&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;companies$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;api&lt;/span&gt;&lt;span class="se"&gt;\/&lt;/span&gt;&lt;span class="sr"&gt;companies&lt;/span&gt;&lt;span class="se"&gt;\/[\w&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;\/(&lt;/span&gt;&lt;span class="sr"&gt;agents|issues&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PATCH&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; get a &lt;code&gt;405&lt;/code&gt;, any other path gets a &lt;code&gt;403&lt;/code&gt;. If you point it at an authenticated Paperclip, the API key is added on the server side only: it never reaches the browser, and the browser's own cookies are never forwarded upstream. There is deliberately no &lt;code&gt;--token&lt;/code&gt; flag, because flags show up in the process list.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. "Needs you" from real signals
&lt;/h3&gt;

&lt;p&gt;For Claude Code, Cubicle uses the official hooks. A tiny script rewrites &lt;code&gt;~/.cubicle/claude-code.json&lt;/code&gt; on every event:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Claude Code event&lt;/th&gt;
&lt;th&gt;In the office&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;PreToolUse&lt;/code&gt;, &lt;code&gt;PostToolUse&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Types at the desk; bubble shows e.g. &lt;code&gt;Edit checkout.php&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;PermissionRequest&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Raises its hand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Stop&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Goes to the lounge&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;SessionEnd&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Leaves the office&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The hook always exits 0 and prints nothing, so it can never block a tool call or add tokens to the context. One thing I had to handle: Claude Code also sends a notification after a minute of idling ("waiting for your input"). Treating that as "needs you" made every idle session raise its hand, so those are ignored.&lt;/p&gt;

&lt;p&gt;For Paperclip, the interesting signal was hiding in the issue data. When an agent asks the board a question, Paperclip records it in the issue's &lt;code&gt;reviewAttention.paths&lt;/code&gt; with the board as the responder. Often the agent is already busy with another issue, so its own status says &lt;code&gt;running&lt;/code&gt;. Cubicle keeps it typing, but its bubble flashes the waiting issue's ID every few seconds and the card links straight to it. The first time I turned this on, it found two questions I didn't know were waiting for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Paperclip (default, expects it on :3100)&lt;/span&gt;
npx @caglarutkuguler/cubicle

&lt;span class="c"&gt;# Claude Code&lt;/span&gt;
npx @caglarutkuguler/cubicle install-hooks
npx @caglarutkuguler/cubicle &lt;span class="nt"&gt;--source&lt;/span&gt; claude-code

&lt;span class="c"&gt;# anything that can write a small JSON file&lt;/span&gt;
npx @caglarutkuguler/cubicle &lt;span class="nt"&gt;--source&lt;/span&gt; ./agents.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;http://127.0.0.1:3200&lt;/code&gt;. Add &lt;code&gt;?kiosk&lt;/code&gt; for a full-screen view on a TV or second monitor.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's next
&lt;/h2&gt;

&lt;p&gt;A few issues are open and labelled for first-time contributors: a new UI language, per-agent spend for Paperclip, an example adapter for Codex or Gemini CLI, and a replay mode to watch a whole day in 30 seconds. PRs welcome, as long as they keep the two rules: no dependencies, and read-only.&lt;/p&gt;

&lt;p&gt;It's MIT licensed: &lt;a href="https://github.com/caglarutkuguler/cubicle" rel="noopener noreferrer"&gt;github.com/caglarutkuguler/cubicle&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>jQuery's .trigger('submit') drops the submit button, and your backend may be checking for it</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Tue, 15 Sep 2026 07:36:53 +0000</pubDate>
      <link>https://dev.to/megventure/jquerys-triggersubmit-drops-the-submit-button-and-your-backend-may-be-checking-for-it-nif</link>
      <guid>https://dev.to/megventure/jquerys-triggersubmit-drops-the-submit-button-and-your-backend-may-be-checking-for-it-nif</guid>
      <description>&lt;p&gt;A contact form was posting and leaving nothing behind. No message stored, no e-mail sent, no thread created — and no error either. The page just reloaded, empty and calm, as if the visitor had never pressed anything.&lt;/p&gt;

&lt;p&gt;The cause is a one-line detail about how forms are submitted from JavaScript, and it is not specific to the framework we hit it in. If any part of your backend decides whether to act by testing for a submit button's name, you can hit this too.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the code did
&lt;/h2&gt;

&lt;p&gt;The form was protected by an invisible CAPTCHA. Tokens for that kind of CAPTCHA expire in about two minutes and are single-use, so the sensible design is to fetch a fresh token at the moment of submit rather than on page load:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;$form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;grecaptcha&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;siteKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;contact&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;$form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;[name="g-recaptcha-response"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;val&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;$form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;          &lt;span class="c1"&gt;// &amp;lt;- here&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Intercept, get the token, put it in the hidden field, submit for real. That is the standard shape, and it appears in a lot of tutorials.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually goes over the wire
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;$form.trigger('submit')&lt;/code&gt; does not simulate a click. jQuery, finding no more handlers to run, calls the element's &lt;strong&gt;native&lt;/strong&gt; &lt;code&gt;form.submit()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A native submit has no &lt;em&gt;submitter&lt;/em&gt;. The HTML spec is explicit that the entry list is built from the form's controls, and a submit button contributes its &lt;code&gt;name&lt;/code&gt;/&lt;code&gt;value&lt;/code&gt; pair &lt;strong&gt;only when it is the button that activated the submission&lt;/strong&gt;. Nothing activated anything here, so:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the clicked button's &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;value&lt;/code&gt; are simply absent from the POST body;&lt;/li&gt;
&lt;li&gt;every other field is present and correct.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So you get a POST that looks complete in the Network tab. Unless you know which key is missing, nothing jumps out.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why that is fatal for some backends
&lt;/h2&gt;

&lt;p&gt;Plenty of server code — PrestaShop, older WordPress plugins, hand-rolled PHP, anything with several forms posting to the same controller — decides &lt;em&gt;what to do&lt;/em&gt; by asking which button was pressed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Tools&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;isSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'submitMessage'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// validate, store, send mail&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;isSubmit('submitMessage')&lt;/code&gt; is a presence test on &lt;code&gt;$_POST['submitMessage']&lt;/code&gt;. With the submitter dropped, that key is not there, the branch never runs, and the controller falls through to rendering the page again.&lt;/p&gt;

&lt;p&gt;This is the worst possible failure shape:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No error.&lt;/strong&gt; The controller did not fail; it was never asked to do anything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No validation message.&lt;/strong&gt; Validation lives inside the branch that did not run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No log line.&lt;/strong&gt; Nothing threw.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The CAPTCHA looks innocent.&lt;/strong&gt; Our module's own "blocked submission" counter never moved, which was the clue that finally mattered: the request had not even reached the verification step. We had been tuning the score threshold for a week. The threshold was never involved.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We reproduced it on PrestaShop 9.1.4: the contact form posted, left no thread, no message and no mail, and displayed nothing.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;Re-attach the activating button before submitting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;submitPreservingButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$form&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tagName&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;FORM&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;closest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;$form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;submitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;originalEvent&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;originalEvent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;submitter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button[type="submit"][name], input[type="submit"][name]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;submitter&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;submitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input[type="hidden"][name="&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;submitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;keep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nx"&gt;keep&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;keep&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;submitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="c1"&gt;// Buttons often carry an empty value; a presence test is happy either&lt;/span&gt;
        &lt;span class="c1"&gt;// way, but an empty string is easy to lose in transit.&lt;/span&gt;
        &lt;span class="nx"&gt;keep&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;submitter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;keep&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;submit&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three details worth keeping:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;event.submitter&lt;/code&gt; first.&lt;/strong&gt; Modern browsers put the activating element on the submit event. Use it when it is there; it is the only source that is actually correct when a form has several named submit buttons.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fall back to the first named submit control.&lt;/strong&gt; Older browsers, and synthetic submits with no event, need something. It is a guess, but on a single-button form it is the right guess.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do not add the hidden input twice.&lt;/strong&gt; A user who submits, fails validation and submits again would otherwise accumulate duplicates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are not carrying jQuery for other reasons, the modern equivalent is &lt;code&gt;form.requestSubmit(submitter)&lt;/code&gt;, which does the right thing natively — it fires the submit event &lt;em&gt;and&lt;/em&gt; includes the submitter. It is widely supported now. &lt;code&gt;requestSubmit()&lt;/code&gt; is what &lt;code&gt;form.submit()&lt;/code&gt; should always have been.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part that generalises
&lt;/h2&gt;

&lt;p&gt;Two APIs that look interchangeable are not:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;fires &lt;code&gt;submit&lt;/code&gt; event&lt;/th&gt;
&lt;th&gt;includes submitter&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;user clicks the button&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;form.requestSubmit(btn)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;td&gt;yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;form.submit()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;no&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;no&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;$(form).trigger('submit')&lt;/code&gt; with no handlers left&lt;/td&gt;
&lt;td&gt;ends in &lt;code&gt;form.submit()&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;no&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;And a backend convention that looks harmless — "check which button was pressed" — turns that difference into a silent no-op.&lt;/p&gt;

&lt;p&gt;If you are debugging a form that posts and does nothing, before you touch validation, tokens or thresholds: open the Network tab, look at the actual form data, and check whether the submit button's own name is in there. It is a ten-second check that we did not do for an embarrassingly long time.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Found while maintaining PrestaShop modules at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;. The same shape affects account creation, newsletter sign-up and checkout on that platform, since all four are gated on a button name.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>php</category>
      <category>webdev</category>
      <category>jquery</category>
    </item>
    <item>
      <title>Your database dumps are protected by an .htaccess. Your server may not read it.</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Thu, 27 Aug 2026 06:40:02 +0000</pubDate>
      <link>https://dev.to/megventure/your-database-dumps-are-protected-by-an-htaccess-your-server-may-not-read-it-cgb</link>
      <guid>https://dev.to/megventure/your-database-dumps-are-protected-by-an-htaccess-your-server-may-not-read-it-cgb</guid>
      <description>&lt;p&gt;We ran an audit of our own shop this summer. Three &lt;code&gt;.sql&lt;/code&gt; files were sitting in the web root, downloadable by anyone who typed the right URL. Nobody had been careless in any dramatic way. They were the ordinary residue of ordinary work: an export taken before an upgrade, a copy made to test something locally, a dump someone pulled through a hosting panel and never came back for.&lt;/p&gt;

&lt;p&gt;That is the honest version of how this happens, and it is worth writing down, because the usual response — "PrestaShop protects the backup folder" — is true and does not help.&lt;/p&gt;

&lt;h2&gt;
  
  
  What PrestaShop actually does
&lt;/h2&gt;

&lt;p&gt;Credit where it is due. A fresh install ships &lt;code&gt;admin-dev/backups/.htaccess&lt;/code&gt;, and it contains exactly what you would want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight apache"&gt;&lt;code&gt;&lt;span class="c"&gt;# Apache 2.2&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="sr"&gt; !mod_authz_core.c&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="nc"&gt;Order&lt;/span&gt; deny,allow
    &lt;span class="nc"&gt;Deny&lt;/span&gt; &lt;span class="ss"&gt;from&lt;/span&gt; &lt;span class="ss"&gt;all&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="c"&gt;# Apache 2.4&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="sr"&gt; mod_authz_core.c&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="nc"&gt;Require&lt;/span&gt; &lt;span class="ss"&gt;all&lt;/span&gt; denied
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nl"&gt;IfModule&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is an &lt;code&gt;index.php&lt;/code&gt; stub next to it, so a directory listing gives you nothing either. The DB Backup page under Advanced Parameters writes into that folder, and &lt;code&gt;PrestaShopBackup&lt;/code&gt; builds the name with a random component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nv"&gt;$backupDir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'/backups/'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="nv"&gt;$rand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;dechex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;mt_rand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mh"&gt;0xFFFFFFFF&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;mt_getrandmax&lt;/span&gt;&lt;span class="p"&gt;())));&lt;/span&gt;
&lt;span class="nv"&gt;$date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;time&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nv"&gt;$backupfile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getRealBackupPath&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$date&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'-'&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$rand&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'.sql'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the design is: the folder denies everything, and the filename is not guessable at a glance. Two layers. Fine.&lt;/p&gt;

&lt;p&gt;Now the part that matters. &lt;strong&gt;The folder is inside the web root&lt;/strong&gt; — &lt;code&gt;_PS_ADMIN_DIR_&lt;/code&gt; is a directory your web server serves. Nothing about that path is outside the document root. The entire protection is one text file that the web server has to choose to read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four ways the one text file stops working
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Your server does not read &lt;code&gt;.htaccess&lt;/code&gt; at all.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;nginx has no such mechanism. It never had one. An &lt;code&gt;.htaccess&lt;/code&gt; file on an nginx host is a text file with no special meaning whatsoever — the deny-all block is inert, and the URL resolves straight to the dump. The same is true of Apache configured with &lt;code&gt;AllowOverride None&lt;/code&gt;, which is the recommended production setting in Apache's own documentation for performance reasons.&lt;/p&gt;

&lt;p&gt;A large share of managed PrestaShop hosting is nginx, or nginx in front of Apache with static files served by nginx directly, which produces exactly the same outcome for a &lt;code&gt;.sql&lt;/code&gt; file. If you have never checked which one you are on, you do not know whether that file is doing anything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. The folder can come back without it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PrestaShopBackup&lt;/code&gt; writes the dump. It does not write the &lt;code&gt;.htaccess&lt;/code&gt;. That file exists because it shipped with the install, so it survives only as long as nobody removes the folder. Delete the backups folder to clear space and let something recreate it, deploy with a hand-written file list that leaves dotfiles out, restore from an archive built with a glob that skipped them, and the folder comes back with dumps in it and nothing guarding it.&lt;/p&gt;

&lt;p&gt;We know this happens because our own cleanup module writes the pair back if they are missing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;is_dir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$dir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;file_exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$dir&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'.htaccess'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="nb"&gt;file_put_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$dir&lt;/span&gt;&lt;span class="mf"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;'.htaccess'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;Files ~ &lt;/span&gt;&lt;span class="se"&gt;\"&lt;/span&gt;&lt;span class="s2"&gt;\.(sql|gz)$\"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;\nOrder&lt;/span&gt; &lt;span class="nc"&gt;Allow&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Deny\nDeny&lt;/span&gt; &lt;span class="n"&gt;from&lt;/span&gt; &lt;span class="n"&gt;all\n&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Files&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;");
}
if (is_dir(&lt;/span&gt;&lt;span class="nv"&gt;$dir&lt;/span&gt;&lt;span class="s2"&gt;) &amp;amp;&amp;amp; !file_exists(&lt;/span&gt;&lt;span class="nv"&gt;$dir&lt;/span&gt;&lt;span class="s2"&gt;.'index.php')) {
    @file_put_contents(&lt;/span&gt;&lt;span class="nv"&gt;$dir&lt;/span&gt;&lt;span class="s2"&gt;.'index.php', "&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="nf"&gt;php\nheader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Location: ../'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="n"&gt;\nexit&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="n"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;");
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You do not write that check unless you have seen the folder without them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. The shop's main &lt;code&gt;.htaccess&lt;/code&gt; does not cover it either.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is tempting to assume PrestaShop's generated root &lt;code&gt;.htaccess&lt;/code&gt; — the one the Traffic &amp;amp; SEO page rewrites — has a rule for this. It does not. In 8.2 the only &lt;code&gt;&amp;lt;Files&amp;gt;&lt;/code&gt; block it generates protects &lt;code&gt;composer.lock&lt;/code&gt;. There is no rule for &lt;code&gt;.sql&lt;/code&gt;, no rule for the backups path, no &lt;code&gt;Options -Indexes&lt;/code&gt;. So regenerating your &lt;code&gt;.htaccess&lt;/code&gt;, which merchants do fairly often, adds nothing here and (if you had hand-edited a rule in) removes it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Most dumps never went through that page.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where ours came from, and I suspect where most of them come from. A dump produced by phpMyAdmin's "save on server", by a hosting panel's export button, by &lt;code&gt;mysqldump &amp;gt; backup.sql&lt;/code&gt; in whatever directory the SSH session happened to open in — none of those land in the protected folder, and none of them get a random name. They get the name you chose, which is &lt;code&gt;backup.sql&lt;/code&gt;, or &lt;code&gt;db.sql&lt;/code&gt;, or &lt;code&gt;shop-2026-08.sql.gz&lt;/code&gt;, in the directory where you were working, which is the web root.&lt;/p&gt;

&lt;p&gt;No amount of correctness in &lt;code&gt;PrestaShopBackup&lt;/code&gt; touches this case.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is in the file
&lt;/h2&gt;

&lt;p&gt;Worth being specific, because "a database dump" sounds abstract and the contents are not.&lt;/p&gt;

&lt;p&gt;A PrestaShop dump contains &lt;code&gt;ps_customer&lt;/code&gt; and &lt;code&gt;ps_address&lt;/code&gt;: names, email addresses, postal addresses, phone numbers, and customer password hashes, for every account the shop has ever had. It contains &lt;code&gt;ps_orders&lt;/code&gt; with what everyone bought and &lt;code&gt;ps_order_payment&lt;/code&gt; with transaction references. It contains &lt;code&gt;ps_employee&lt;/code&gt;, which is your back-office accounts and their password hashes. And it contains &lt;code&gt;ps_configuration&lt;/code&gt;, which is where PrestaShop and every module you have installed keep their settings — including the SMTP credentials your shop sends mail with, webservice keys, and whatever API credentials your payment and shipping modules were configured with.&lt;/p&gt;

&lt;p&gt;That last one is why "we deleted the file" is not the end of the incident. If a dump was reachable, the credentials in it have to be treated as disclosed, and that means rotating them, not just removing the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checking your own shop, in about two minutes
&lt;/h2&gt;

&lt;p&gt;All of this is on your own server, so there is nothing clever involved:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Find them.&lt;/strong&gt; From the shop root: &lt;code&gt;find . -maxdepth 3 \( -name '*.sql' -o -name '*.sql.gz' -o -name '*.sql.zip' \)&lt;/code&gt;. Include your archive extensions. A full-site &lt;code&gt;.zip&lt;/code&gt; or &lt;code&gt;.tar.gz&lt;/code&gt; from a migration is the same problem wearing a different extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ask your own server for one.&lt;/strong&gt; Request the exact URL of a file you just found, from outside, with a browser that is not logged in. This is the only test that answers the question, because it is the server's actual configuration answering, not your assumption about it. A &lt;code&gt;403&lt;/code&gt; is what you want. A &lt;code&gt;200&lt;/code&gt; with a download is the finding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Check the backups folder specifically&lt;/strong&gt;, including whether &lt;code&gt;.htaccess&lt;/code&gt; and &lt;code&gt;index.php&lt;/code&gt; are still there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Know which server you are on.&lt;/strong&gt; &lt;code&gt;nginx -v&lt;/code&gt;, or the &lt;code&gt;Server&lt;/code&gt; response header, or ask your host. If the answer is nginx, every &lt;code&gt;.htaccess&lt;/code&gt; on that host is decoration.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The fix that does not depend on the answer
&lt;/h2&gt;

&lt;p&gt;Move dumps out of the document root. That is the whole fix, and it is the only one that survives a server migration, a control-panel change, or a colleague who does not know the rule. A directory one level above the web root, or an object store, or your laptop. If the file is not addressable by URL, no server configuration can accidentally serve it.&lt;/p&gt;

&lt;p&gt;Everything else is mitigation, in descending order of reliability:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A server-level rule&lt;/strong&gt;, in the nginx &lt;code&gt;server&lt;/code&gt; block or the Apache vhost, not in an &lt;code&gt;.htaccess&lt;/code&gt;. On nginx: a &lt;code&gt;location&lt;/code&gt; matching your dump extensions with &lt;code&gt;deny all;&lt;/code&gt; and &lt;code&gt;return 404;&lt;/code&gt;. In a vhost it cannot be silently disabled by &lt;code&gt;AllowOverride&lt;/code&gt;, and it does not vanish when a folder is recreated.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete the dump when you are done with it.&lt;/strong&gt; Almost every exposed dump was needed for one afternoon two years ago. A backup you are keeping deliberately belongs in your backup system, which is not a folder in your shop.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rotate what was in it&lt;/strong&gt; if it was ever reachable. Employee passwords, webservice keys, module API credentials, SMTP.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And if the file is reachable, do not stop at the shop. Search engines index what they can reach, so a dump that sat in the open for a while may be findable independently of your server, which means removing the file is step one of two.&lt;/p&gt;

&lt;h2&gt;
  
  
  Our own module is not innocent here
&lt;/h2&gt;

&lt;p&gt;Since this is a field note and not marketing: our cleanup module writes its backups into that same folder, and its filenames look like &lt;code&gt;prestacleaner_check-fix-20260827-084500.sql.gz&lt;/code&gt;. That is a prefix, a date and a time. It is entirely predictable to anyone who knows the format, which is now everyone reading this.&lt;/p&gt;

&lt;p&gt;That is a deliberate trade — the files have to be recognisable in a list so the merchant can tell which is which, and so cleanup never touches a backup somebody else's tool wrote. But it means the naming contributes nothing to secrecy and the folder-level deny is carrying all of it, which is precisely the arrangement this post is about. On an nginx host, that is one layer, and the layer is not there.&lt;/p&gt;

&lt;p&gt;The point of writing it down is that we found this in our own shop, by looking. The looking is the part that generalises.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;From maintaining around sixty PrestaShop modules at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;. Verified against PrestaShop 8.2 source: &lt;code&gt;classes/PrestaShopBackup.php&lt;/code&gt;, &lt;code&gt;classes/Tools.php&lt;/code&gt;, &lt;code&gt;admin-dev/backups/.htaccess&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>security</category>
      <category>devops</category>
      <category>webdev</category>
    </item>
    <item>
      <title>PrestaShop's Configuration table is global, and uninstalling your module can delete someone else's settings</title>
      <dc:creator>MEG Venture &amp; Consulting Ltd.</dc:creator>
      <pubDate>Wed, 26 Aug 2026 11:36:32 +0000</pubDate>
      <link>https://dev.to/megventure/prestashops-configuration-table-is-global-and-uninstalling-your-module-can-delete-someone-elses-3ac2</link>
      <guid>https://dev.to/megventure/prestashops-configuration-table-is-global-and-uninstalling-your-module-can-delete-someone-elses-3ac2</guid>
      <description>&lt;p&gt;&lt;code&gt;Configuration::updateValue('width', 40)&lt;/code&gt; looks harmless. It is one row in &lt;code&gt;ps_configuration&lt;/code&gt;, it holds your module's setting, and it works.&lt;/p&gt;

&lt;p&gt;It works until a second module does the same thing. &lt;code&gt;ps_configuration&lt;/code&gt; is a shop-wide key/value table with no namespace and no owner column. Two modules that pick the same name share one row: whichever saves last wins, and neither has any way to notice. Then one of them is uninstalled, runs its tidy-up, and deletes it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;uninstall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Configuration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;deleteByName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'width'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// whose width?&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;uninstall&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That is the bug we found in one of our own modules. It stored &lt;code&gt;theme&lt;/code&gt;, &lt;code&gt;background&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;effect&lt;/code&gt; as bare names. Fixing that one module was easy. The interesting part was the question it raised: how many of the others do this?&lt;/p&gt;

&lt;h2&gt;
  
  
  The sweep, and why the first one was wrong
&lt;/h2&gt;

&lt;p&gt;We have 57 module repositories. Grepping them for &lt;code&gt;Configuration::&lt;/code&gt; calls produces a lot of hits, most of them fine, so the sweep needs a filter. Our first filter was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A name that is UPPERCASE with underscores is prefixed. Anything else is suspect.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is wrong, and it is wrong in the direction that hides bugs. It passed three names that are uppercase, underscored, and completely unprefixed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;API_DATE_FROM&lt;/code&gt; and &lt;code&gt;PRODUCT_PAGE_FRONT_ENABLE&lt;/code&gt; — in a seller-dashboard module&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;VIDEO_PRODUCTS_NBR&lt;/code&gt; — in a product-video module&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;API_*&lt;/code&gt; is about as generic as a key can get. It looks disciplined. It is not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The right test is not capitalisation, it is derivation: does the prefix come from the module's own name?&lt;/strong&gt; &lt;code&gt;CG_&lt;/code&gt; for &lt;code&gt;combinationgrid&lt;/code&gt;, &lt;code&gt;CSF_&lt;/code&gt; for &lt;code&gt;customerservicefile&lt;/code&gt;, &lt;code&gt;PCT_&lt;/code&gt; for &lt;code&gt;productcustomtab&lt;/code&gt; — initialisms are fine, because they derive. &lt;code&gt;API_&lt;/code&gt; derives from nothing.&lt;/p&gt;

&lt;p&gt;We re-ran the sweep with that criterion. Total: five real cases across the catalogue, four found in the first pass and one found later, by accident, during unrelated work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Not every cross-module read is a bug
&lt;/h2&gt;

&lt;p&gt;The sweep surfaced plenty of modules reading keys with another module's prefix. Almost all of those were deliberate — two modules that integrate on purpose, one reading the other's setting to decide whether to render something. That is a dependency, and it should be documented, but it is not this bug.&lt;/p&gt;

&lt;p&gt;The distinction that matters is &lt;strong&gt;write and delete, not read&lt;/strong&gt;. Reading a foreign key is a coupling decision. Writing one is a collision. Deleting one on uninstall is data loss in someone else's module.&lt;/p&gt;

&lt;p&gt;One finding was a false positive worth mentioning because of what it turned out to be. A module appeared to touch a bare key named &lt;code&gt;theme&lt;/code&gt;. The hit was in &lt;code&gt;tests/ReviewNudgeTest.php&lt;/code&gt;, in a fixture that plants a foreign unprefixed key and then asserts that uninstall left it alone. It was not the bug; it was the test that proves the bug is absent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the risk actually sits
&lt;/h2&gt;

&lt;p&gt;In all five cases, the modules' &lt;em&gt;current&lt;/em&gt; settings were properly prefixed. Nobody was actively writing bare names. The damage was concentrated in one place: legacy cleanup in &lt;code&gt;uninstall()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The pattern goes like this. Version 1.x stored &lt;code&gt;show_notavailable&lt;/code&gt; and &lt;code&gt;colorshape&lt;/code&gt;. Version 2.x migrated to &lt;code&gt;COLORSONPRODUCTLIST_*&lt;/code&gt; and, being tidy, kept deleting the old names on uninstall so a reinstall would start clean. The intent is right. The effect is that uninstalling this module deletes a row that, on some other shop, belongs to a different module entirely.&lt;/p&gt;

&lt;p&gt;The same lines had also been copied into the &lt;code&gt;upgrade-2.0.0.php&lt;/code&gt; scripts — same bug class, second location, and easy to miss if you only audit &lt;code&gt;uninstall()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;Deleting your own historical leftovers is not worth risking another module's data. Two options, in order of preference:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Stop deleting them.&lt;/strong&gt; The residue costs a few bytes in &lt;code&gt;ps_configuration&lt;/code&gt; and harms nothing. This is what we did in every case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;uninstall&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Only this module's own prefixed keys. The bare 1.x names&lt;/span&gt;
    &lt;span class="c1"&gt;// ('show_notavailable', 'colorshape', ...) are left alone: configuration&lt;/span&gt;
    &lt;span class="c1"&gt;// is shop-wide and the module cannot prove another module does not own&lt;/span&gt;
    &lt;span class="c1"&gt;// a row by one of those names.&lt;/span&gt;
    &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;array_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;defaultSettings&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Configuration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;deleteByName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;parent&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;uninstall&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The comment is load-bearing. Without it, the next person to read this file sees dead cleanup code and helpfully restores it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. If you must delete, prove ownership first.&lt;/strong&gt; Check that the stored value is a shape only your module writes. This is fragile, and it is only worth it when the leftover actually causes a problem.&lt;/p&gt;

&lt;p&gt;Full prefix migration — read the bare key, write the prefixed one, keep the old row — is a bigger change and it is only warranted when the module is still &lt;em&gt;reading&lt;/em&gt; bare names. If your current keys are already prefixed, the uninstall step is the whole bug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making it stay fixed
&lt;/h2&gt;

&lt;p&gt;A grep sweep finds this once. A test keeps it found. Ours plants foreign keys and asserts uninstall left them alone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Configuration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nv"&gt;$store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s1"&gt;'MYMODULE_SETTING'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'1'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'MYMODULE_OTHER'&lt;/span&gt;    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'tok'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'theme'&lt;/span&gt;             &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'another-modules-value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s1"&gt;'OTHERMODULE_THING'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'another-modules-value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nv"&gt;$module&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;uninstall&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Configuration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'theme'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'another-modules-value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'a bare foreign key was not touched'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Configuration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'OTHERMODULE_THING'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'another-modules-value'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="s1"&gt;'another module prefixed key was not touched'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Configuration&lt;/code&gt; is a small enough surface to stub — get, updateValue, deleteByName over an array — so this runs as plain &lt;code&gt;php tests/ConfigurationKeyTest.php&lt;/code&gt; with no PrestaShop and no database. Cheap enough that every module can carry one.&lt;/p&gt;

&lt;p&gt;If you are running the sweep yourself, a per-module negative match is more reliable than a global positive one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deleteByName\('(?!MYPREFIX_)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it once per module with that module's own prefix substituted in. Semi-generic names like &lt;code&gt;API_*&lt;/code&gt; slip past hand-written positive patterns; they do not slip past "anything that is not my prefix".&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this is worth an hour of your time
&lt;/h2&gt;

&lt;p&gt;The failure mode is invisible from inside either module. Module A's setting resets and its author blames a caching layer. Module B's uninstall is the cause and its author never finds out, because it happened on someone else's shop, three months later, after an unrelated support ticket.&lt;/p&gt;

&lt;p&gt;Nothing errors. Nothing is logged. The support conversation goes nowhere, because both authors are looking at code that is correct in isolation.&lt;/p&gt;

&lt;p&gt;Grep your own modules for &lt;code&gt;deleteByName&lt;/code&gt; and read every line of what follows. It is a short list.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;We maintain around sixty PrestaShop modules at &lt;a href="https://megventure.com" rel="noopener noreferrer"&gt;MEG Venture&lt;/a&gt;. The audit above took an afternoon and closed five bugs that no customer had reported and no test could have caught, because the damage happens in someone else's code.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>prestashop</category>
      <category>php</category>
      <category>refactoring</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
