Create a solution on our side:
- apply one patch operation at a time, introduce an index and count
- Include the index in the PatchPathException
Background:
we're currently applying patch documents by doing something like the following (pseudo code):
$patcher->patch( $target, $patchDocument );
where $patchDocument is a list of patch operations [ $op1, $op2, ..., $opN ].
the workaround (to be removed once we have the proper solution upstream, see T368414) would be to do the following
foreach ( $patchDocument as $i => $op ) { try { $patcher->patch( $target, [ $op ] ); } catch ( PathException $e ) { // $i is the index of the operation with the bad path } }
the advantage of applying them one by one is that we know which one exactly is problematic because we have access to the index $i whereas in the code snippet above we don't.