Evolution of the cluster optical galaxy luminosity function in the CFHTLS: breaking the degeneracy between mass and redshift