Assume wiki has pages A and B with links and categories: A(l1,l2,l3,l4,l5,c1,c2,c3), B(l1,c1). This is how API behaves now:
1 req) prop=categories|links & generator=allpages & gaplimit=1 & pllimit=2 & cllimit=2
1 res) A(l1,l2,c1,c2), gapcontinue=B, plcontinue=l3, clcontinue=c3
client ignores gapcontinue because there are others, and adds pl & cl continues:
2 req) initial & plcontinue=l3 & clcontinue=c3
2 res) A(l3,l4,c3), gapcontinue=B, plcontinue=l5
this is where a *potential" for the bug is: client must understand that since there is no more clcontinue, but there is plcontinue, there are no more categories in this set of pages, so it should not ask for prop=categories until it finishes with plcontinue. Once done, it should resume prop=categories and also add gapcontinue=B.
3 bad req) initial & plcontinue=l5
3 bad res) A(l5,c1,c2), gapcontinue=B, clcontinue=c3
3 good req) initial but with prop=links only & plcontinue=l5
3 good res) A(l5) & gapcontinue=B
4 req) initial & gapcontinue=B
4 res) B(l1,c1) -- done
I think this puts too much unneeded burden on the client code to handle these cases correctly. Instead, API should be simplified to return clcontinue=| in result #2, and results 1 and 2 should have gapcontinue=A. Client could simply merge all resulting continue values into following requests, and greatly simplify all the code for the most common "get everything I requested" scenario, and hence should be the default behavior:
1 req) prop=categories|links & generator=allpages & gaplimit=1 & pllimit=2 & cllimit=2
1 res) A(l1,l2,c1,c2), gapcontinue=, plcontinue=l3, clcontinue=c3
2 req) initial & gapcontinue= & plcontinue=l3 & clcontinue=c3
2 res) A(l3,l4,c3), gapcontinue=, plcontinue=l5, clcontinue=|
3 req) initial & gapcontinue= & plcontinue=l5 & clcontinue=|
3 res) A(l5) & gapcontinue=B, plcontinue=, clcontinue=
4 req) initial & gapcontinue=B & plcontinue= & clcontinue=
4 res) B(l1,c1) -- no continue section, done