Context. There is some disagreement about the abundance of faint galaxies in high-redshift clusters, with contradictory results in the literature arising from studies of the optical galaxy luminosity function (GLF) for small cluster samples. Aims. We compute GLFs for one of the largest medium-to-high-redshift (0.4 ≤ z < 0.9) cluster samples to date in order to probe the abundance of faint galaxies in clusters. We also study how the GLF depends on cluster redshift, mass, and substructure and compare the GLFs of clusters with those of the field. We separately investigate the GLFs of blue and red-sequence (RS) galaxies to understand the evolution of different cluster populations. Methods. We calculated the GLFs for 31 clusters taken from the DAFT/FADA survey in the B, V, R, and I rest-frame bands. We used photometric redshifts computed from BVRIZ J images to constrain galaxy cluster membership. We carried out a detailed estimate of the completeness of our data. We distinguished the red-sequence and blue galaxies using a V − I versus I colour−magnitude diagram. We studied the evolution of these two populations with redshift. We fitted Schechter functions to our stacked GLFs to determine average cluster characteristics. Results. We find that the shapes of our GLFs are similar for the B, V, R, and I bands with a drop at the red GLF faint ends that is more pronounced at high redshift: α red ∼ −0.5 at 0.40 ≤ z < 0.65 and α red > 0.1 at 0.65 ≤ z < 0.90. The blue GLFs have a steeper faint end (α blue ∼ −1.6) than the red GLFs, which appears to be independent of redshift. For the full cluster sample, blue and red GLFs meet at M V = −20, M R = −20.5, and M I = −20.3. A study of how galaxy types evolve with redshift shows that late-type galaxies appear to become early types between z ∼ 0.9 and today. Finally, the faint ends of the red GLFs of more massive clusters appear to be richer than less massive clusters, which is more typical of the lower redshift behaviour. Conclusions. Our results indicate that these clusters form at redshifts higher than z = 0.9 from galaxy structures that already have an established red sequence. Late-type galaxies then appear to evolve into early types, enriching the red sequence between this redshift and today. This effect is consistent with the evolution of the faint-end slope of the red sequence and the galaxy type evolution that we find. Finally, faint galaxies accreted from the field environment at all redshifts might have replaced the blue late-type galaxies that converted into early types, explaining the lack of evolution in the faint-end slopes of the blue GLFs.