It's probably even safe to eat without cooking again; the refrigerator is likely only about 10 degrees colder, and that generally translates to accelerating rates of spoilage (mostly growth of pathogens) by a factor of 3-5 or so. For example. at 10C (50F), E. coli only manages to divide once every 8 hours or so (see Ratkowsky et al., "Relationship Between Temperature and Growth Rate of Bacterial Cultures", J. Bacteriology, vol 169, p. 1 (1982) for a not-very-clear example of growth curves--I've seen these curves online, but unfortunately I tried and failed to find an easily accessible one this time).
It's almost certainly safe to eat with cooking (fully, to at least ~160 at the center), which would kill anything that managed to grow on the ham. The only thing to worry about with well-cooked food is whether bacteria or fungi have managed to produce so many toxic chemicals that the food will make you ill--and in this case, it's been too cold. (At those temperatures, not only is growth slow, but most anything is slow, including production of anything toxic.)
So I'd say--cook away, enjoy, and don't worry about it.
P.S. I have in practice eaten ham left out at warmer temperatures for longer.
Edit: In response to a comment about bacterial toxin production, I want to reiterate that colder temperatures slow down metabolism of just about everything, including toxin production. This is because, at a basic physical level, reaction rates are governed by the Arrhenius equation which translates, for simple reactions, to a doubling of reaction rates for ~10C increase in temperature. Of course, organisms like bacteria have more complex interactions, but this still gives an order of magnitude estimate. Furthermore, research has been done on production of bacterial toxins. For example, Skinner & Larkin (J. Food Protection vol 61 p. 1154 (1998)) wrote a paper called "Conservative Prediction of Time to Clostridium botulinum Toxin Formation for Use with Time-Temperature Indicators To Ensure the Safety of Foods", which gives, for food innoculated with the bacteria, a time-to-detection-of-toxin of 2-3 days at 10C. In fact, they did the research because food storage at open-face refigerators in stores often allows products to get up to as high as 10C (at least as of 1998).
Similarly, in Bonventre and Kempe ("Physiology of Toxin Production by Clostridium botulinum Types A and B, III"), their 10-18C toxin line is flat for 24 hours at the baseline level before creeping up by a factor of 3 or so between 24 and 48 hours (figure 4).
These are just examples, but you find the same general trends everywhere because of the fundamental physical relationship between reaction rates and temperature.
If the food had reached a temperature of 21 C for an unknown amount of time, you should definitely discard it.
See:
How do I know if food left at room temperature is still safe to eat?
As a more general rule, there really is no way to provide a definitive answer; it depends on your specific refrigerator, the cooling power it has, how much air was able to move through the gap, and how much mass was inside the refrigerator to provide a thermal buffer
If you had a refrigerator thermometer and looked at what temperature the interior rose to, if it was below 40 F you are good.
If you don't have a thermometer, you don't know exactly what happened inside.
You must assess how much tolerance for risk you have.
Best Answer
Cheese is a cultured product, so you should follow the advice in the question:
How do you know when a cultured item is no longer safe to consume?
Since it's been acidified and (if it's store bought) probably also pasteurized, it's very unlikely that any harmful bacteria would be able to compete with the "good" bacteria. Most cheese never go bad in this way - they just go sour, rancid and/or grow mold.
Which means that if it looks fine and smells fine and tastes fine, it should still be safe to eat.
Cheese is essentially preserved milk; it was originally intended to be stored at room temperature (before refrigeration existed), it just keeps its quality longer in the fridge.