<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — close_transactions() silently overwrites audit_trail.stamp]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=10725</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=10725&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in close_transactions() silently overwrites audit_trail.stamp.]]></description>
		<lastBuildDate>Tue, 12 May 2026 15:22:50 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[close_transactions() silently overwrites audit_trail.stamp]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=43865#p43865</link>
			<description><![CDATA[<p>After closing an old fiscal year, I noticed `0_audit_trail.stamp` had been rewritten to &quot;now&quot; for every row whose `gl_seq` was updated by the close routine. Rows the close didn&#039;t touch kept their original stamps. This destroys the historical creation timestamp for every GL transaction in the closing year, and breaks any report that relies on `audit_trail.stamp`.</p><p>Two innocent pieces interacting:</p><p>1. `0_audit_trail.stamp` is defined as `TIMESTAMP ... ON UPDATE CURRENT_TIMESTAMP` (FA default, used to track edit time).<br />2.&nbsp; close_transactions() in `includes/db/audit_trail_db.inc` runs `UPDATE 0_audit_trail SET gl_seq=$seq WHERE id=...</p><p>The UPDATE only sets `gl_seq`, but MySQL auto-refreshes `stamp` as a side effect of the `ON UPDATE` clause. The `if ($row[&#039;gl_seq&#039;] != $seq)` guard is why only some rows get hit — exactly the ones being re-sequenced.</p><p>I tried fixing it with the following change</p><p>$sql2 = &quot;UPDATE &quot;.TB_PREF.&quot;audit_trail SET&quot;<br />&nbsp; &nbsp; . &quot; gl_seq=$seq&quot;<br />&nbsp; &nbsp; . &quot; WHERE id=&quot;.$row[&#039;id&#039;];</p><p>to:</p><p>$sql2 = &quot;UPDATE &quot;.TB_PREF.&quot;audit_trail SET&quot;<br />&nbsp; &nbsp; . &quot; gl_seq=$seq,&quot;<br />&nbsp; &nbsp; . &quot; stamp=stamp&quot; // preserve original timestamp<br />&nbsp; &nbsp; . &quot; WHERE id=&quot;.$row[&#039;id&#039;];</p><p>Explicitly listing `stamp` in the SET clause suppresses the `ON UPDATE CURRENT_TIMESTAMP` auto-refresh in MySQL. No schema change needed, and normal `add_audit_trail()` edits are unaffected since they already set `stamp` explicitly.</p><p>Has anyone else hit this? Kindly share your experience.</p><p>Thanks</p>]]></description>
			<author><![CDATA[null@example.com (dz)]]></author>
			<pubDate>Tue, 12 May 2026 15:22:50 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=43865#p43865</guid>
		</item>
	</channel>
</rss>
