Using Mediawiki 1.10.0 I have found that section editing can go awry when there is a <pre> tag containing ===== preceding the section being edited. For example:
Performing an edit on Section Two by replacing "stuff" with "more stuff" results in:
I believe the cause of this is that at the time Parser::strip is invoked during Article::replaceSection the wgParser object has not been initialised by Parser::firstCallInit. As a result, Parser::mTagHooks does not contain the pre hook and so <pre> tags are not being stripped and the section counting is thrown off.