Skip to content

fix(session): Prevent PDO serialization fatal on MODX 3.2.2+ - #18

Open
Ibochkarev wants to merge 1 commit into
GulomovCreative:nextfrom
Ibochkarev:fix/pdo-session-serialization
Open

fix(session): Prevent PDO serialization fatal on MODX 3.2.2+#18
Ibochkarev wants to merge 1 commit into
GulomovCreative:nextfrom
Ibochkarev:fix/pdo-session-serialization

Conversation

@Ibochkarev

Copy link
Copy Markdown
Collaborator

Stop putting the FetchIt instance into FormIt/snippet scriptProperties and harden how action properties are persisted for AJAX submits.

On MODX 3.2.2 + PHP 8.3, session_write_close() fatals with Serialization of 'PDO' is not allowed whenever a frontend template calls FetchIt. The instance holds modX, which holds PDO; once that graph lands in $_SESSION, the response cannot finish. Admin still works because it never runs the snippet.

Also centralize save/load in saveActionProperties() / getActionProperties() and strip objects/resources before writing to session or cache, so the same failure cannot return via Fenom or other object-bearing props.

Breaking for custom snippets: $scriptProperties['FetchIt'] is no longer injected. Use $modx->services->get('FetchIt') instead (already registered in bootstrap.php).

Fixes #17

Putting $this into scriptProperties left a FetchIt→modX→PDO graph in the
session store, which PHP 8.3 cannot serialize on session_write_close after
MODX 3.2.2. Centralize save/load and strip non-serializable values.

Fixes GulomovCreative#17
Co-Authored-By: Cursor <cursoragent@cursor.com>
@Ibochkarev
Ibochkarev marked this pull request as ready for review July 21, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant