217154895c
If $CFG->enable_read_only_sessions_debug was not enabled, debugging could be enabled part-way through a request when restart_with_write_lock was called. This meant that a diff between the initial and final session would be made during write_close(), although the intial session state was never captured. This generated false positives in the logs, and it thought any variable set in the session was a change from the original value. This ensures that debugging is enabled before the debug flag is allowed to change, preventing false positives.