Try at attaching files
And the rest of the files
I'm not fully up to speed on this having read through the code only a few times. Have you got a diff on what has changed as that might help or otherwise comment on the code areas that have changed?
Commenting out the current authenticated user check may have an effect on your process if that was commented out in your changes. I haven't fully run through the chain of events but it may prevent a user authenticated earlier in the chain from proceeding as userid remains null.
Just a guess at this stage as the operation is not fully apparent in my mind. Perhaps someone else may have a suggestion.