Preheat the oven to 180°C fan/200°C/Gas 6. Pour some hot water over the onions in a large mixing bowl and leave them for 10 minutes or so, then drain and peel. Be careful to nip off only the smallest bit of root end with a knife, as you want them to stay intact. De-rind the bacon, if necessary, and if it is in one piece cut it into lardons about the length and twice the thickness of the two short pins on a household plug, or chop up thickly if using rashers.
Sprinkle the flour over a large plate, scatter in a good amount of salt and mix it all together with your fingertips. Melt the butter in a large frying pan over a medium heat with a splash of oil (to help prevent the butter burning). Roll the chicken legs in the flour until very well covered. When the butter is foaming, lower in half the chicken legs skin-side down, where they should sizzle immediately. Thoroughly brown them on both sides, turning them over after approximately 5 minutes. Remove the legs to a large bowl and brown the remaining ones. It is important not to burn the butter, as you are going to fry the onions in it, so adjust the heat when necessary.
Add the peeled onions and cook until they are a deep hazelnut colour. Pour over the vinegar and burn it off completely before scattering over the sugar and swirling the onions around until the sugar has caramelised, making them look even darker and more delicious. Put the onions with the chicken legs, without any of the residual fat.
Put a little oil in a large, heavy flameproof casserole and get the bacon frying in it over a medium heat until it too begins to properly colour. This should take about 10 minutes. Add the celery, garlic, thyme and bay leaves to the pan and cook until the celery has softened – a few minutes or so. Lift the bacon and celery into the bowl, leaving the bacon fat in the bottom of the pan. Take the pan off the heat for a while and wipe the mushroom caps with a damp cloth to remove any grit and oomska. Return the pan to the heat and, when hot, throw in the mushrooms. Any liquid must totally evaporate; at this point the mushrooms will begin to colour quite swiftly. Do this in batches, if needs be, adding the tiniest splash of oil each time. When all the mushrooms are coloured, leave a few in the bottom of the pan and put the rest in the onion bowl. The above colouring stages are important, as the ingredients intensify the flavour of the dish.