That's not as bad as it could have been. The underlying principle of the rules on ceiling fans is that they should be supported directly from the structure or a Fan Support Box which is manufactured and listed for support of ceiling fans. What those requirements effectively forbid is the use of the 8/32 tapped ears of an ordinary fixture box to support the fan. The US National Electric Code (NEC) permits the space inside fixture canopies to be used as a wiring compartment so a fixture box is not required by the NEC. That said, in the absence of a knock out offset from the boxes center, it would be difficult to install the required cable connector in the provided center KO. Had I been faced with the same fan replacement installation I would have used a hole saw or a drill bit and Knock Out (KO) punch to cut an offset KO and then used #10 or larger pan headed wood screws to fasten that canopy pan to the joist. If the fan had been shipped with the center KO already open I would, of course, have installed a KO Blank, which is called a push penny in some areas. Using the new offset KO I would then connected the Non Metallic cable (Type NM) to the box with a listed connector. I will not allege that would be technically code compliant but it would be an effective and safe installation.Installing new fan in daughter's house.
Take down old fan and see this:
View attachment 674013
No junction box; just the mounting plate for the fan. Installer had screwed a screw hook through the middle hole of the plate into ceiling joist until the end of the hook scrapped the face of the plate, thus securing it to the joist.
View attachment 674014
For good measure, two meaningless drywall screws had been used (went into drywall and not joist).
This house never disappoints on how not to but points are given for inventiveness.
As to the original installation it looks like that canopy pan was designed to be installed over the face of a flush mounted fixture box. I suspect that the fan was originally shipped with with a snap in anti short bushing already installed in the center KO or included in the parts packet. That would be to protect the fixture pigtails from damage by the edge of the KO opening. The instructions "included with the listing or labeling" might well have required either the installation of a Fan Support Box
or the use of the portion of the fastener slots which extended past the edge of a "pancake" fixture box to screw larger screws directly into the joist.
to support the canopy pan. "Pancake box" is trade slang for a box which is only as deep as the drywall or plaster in which it is installed with it's open side flush with the ceiling's surface.
The other choice would be a retrofit fan support box which is inserted through the 4 inch round hole in the ceiling. I see by a later post by the discussion starter that he used the pancake fan support box like the one in my first picture.
Since there is only one cable at this fixture I would probably have installed a pancake box because the 4 inch hole that must be cut in the plaster for it's installation does not have to be as carefully centered under the joist. That in spite of the fan's canopy hiding any adjustment cutting and plaster patching. I avoid unneeded additional work wherever I can.