Fundamental Limits of Weak Recovery with Applications to Phase Retrieval