Trying to replace wall mounted light fixture
Here's the situation: A light fixture was mounted on a wall in a room of the house I recently moved into, and this light fixture was controlled by a switch on the same wall. I wanted to replace this light fixture with a new one, and in the process of removing it from the wall I discovered that it was merely screwed directly to a stud without using an electrical box. Whoever installed it made a hole in the wall and ran the wiring inside the wall down to an outlet directly below it. This wire was connected to the screws on the outlet. Upon removing the fixture, the wire that connected it to the outlet fell behind the wall, and I ended up having to pull it through the hole for the outlet in order to remove it.
I know absolutely nothing about wiring or home improvement in general (other than replacing light fixtures which I have been successful at, at least once before). But when I explain this configuration to more knowledgeable people, they say that installing the new light fixture and having it controlled by the switch would require tearing down the wall. When inspecting the outlet, they say it is not even connected to the switch at all. Also, I'm told the switch never controlled the outlet, just the light.
Now, could the configuration I described above have resulted in the proper operation of the light with the switch, and if so, is it possible to somehow install the new light fixture and have it operated by the switch without having to tear down the wall? Let me know if I can clarify anything.
Please note this is in an older house (built in the 1960s?). Thanks in advance