Rewrite download function to avoid un defined constant in php error log