Back to Logbook
Jun 04, 2026 Project: #Biznetrix

CMS AI Generation, CSRF Fix, Social Lead Attribution

productive

Two major threads today. First: CMS AI content generation. Article generation, SEO meta generation, excerpt generation (20–40 words, 1–2 sentences), and re-translation. The CSRF bug was the first thing to fix — the AI modal and translations panel were reading CSRF tokens from non-existent meta tags, so every AI AJAX call was silently failing with a 403. Fixed by using the global csrfName/csrfHash values injected in the header. Added proper timeout handling per provider (120 seconds for blog generation), set PHP time limit to match. Error handling now surfaces actual server messages instead of generic "Request failed" which was making debugging nearly impossible.

Content truncation bug fixed in the base skill: a regex using $ in multiline mode stopped non-greedy matching at the first line break, so multi-paragraph AI responses were being cut at line one. Changed to z (true string end). Full HTML content now captured correctly.

Second thread: social lead attribution. Added social_platform and social_account_id directly to the leads table instead of JSON custom fields. Lead list filtering by source, platform, and account. Lead detail page shows Social & ROI Attribution block. ROI service now attributes leads and revenue correctly across all connected platforms. CMS translation re-translate flow hardened: skips empty fields, shows spinner, tracks success per field, proper aggregate toast at completion.

Lessons Learned

CSRF tokens read from meta tags that are never written to the page is a silent failure mode. If AJAX calls are mysteriously 403-ing with no error shown, check the CSRF source before anything else.