This is an interesting bug, and I'm not sure what is causing it. I suspect it is something in variable_set (like clearing the caches) which causes this problem. Anyway, it is easy to repeat and is consistently repeatable for me:

1. Install PressFlow Transaction
2. Create a new page node that has a php input format with the following body:

// Begin transaction
$txn = new pressflow_transaction();
db_query("INSERT INTO {variable} (name, value) values ('a', 'b')");
variable_set('something', 'value');

3. Preview the node

Expected results:
Run the query: select * from variable where name = 'a'; should return an empty set

Actual results:
The record is inserted and returns a value when that select is run.


greggles’s picture

Component: Code » Documentation
Category: bug » task

After discussing this in IRC, it appears that there's nothing that can be done since variable_set uses LOCK which causes an autocommit.

I suggest adding some docs like on the project page that say

"Due to the use of LOCKS in various parts of Drupal there are certain operations which will force an autocommit if they are done before a rollback. Examples include variable_set and..."

David Strauss’s picture

Status: Active » Closed (fixed)

I've updated documentation with the suggested warning.