Database Write Anomaly: value over-written after update function closes
-
The case:
1. There is only one function in my code triggered when publishing/saving/updating a Page via add_action.
2. It has been proven that 2 values in the same db option are successfully updated using the one array I provide in the call to update_option(), and they don’t get over-written later in the function, (used die() and block-by-block testing to prove it) HOWEVER…
3. After the function terminates, sometime before the updated/published page is update on the Client Side, the [0] element gets over-written with Null in the db, and yet the second value written with the previous update_option() remains intact!!
After 3 days of troubleshooting going over my code I finally called in an HP troubleshooter/programmer and he helped me unit test this until I got certainty on those points.
Now I’m confused where and even how it’s likely to overwrite 1 of the 2 values I updated in the db. I’m hoping it’s not a bug in WP and I really want it to be something I’m ignorant of so I can fix this now… client deadline waiting for my plugin…
FYI – In the pub/sav/upd function, add_post_meta() and update_option() are called, and this same function works in all cases as long as I’m incrementing the elements in the array, as well as over-writing the [0] element- but if I update a post then [0] becomes Null and yet the updated element value later in the array (say [3] for testing purposes) remains.
Any clue or pointer in the right direction is helpful.
- The topic ‘Database Write Anomaly: value over-written after update function closes’ is closed to new replies.