Proper handling of watch with onlyif/unless

This fixes #16647
Merge branch 'f2' into develop