And of the two, to that one whom he consider about to be saved, he said: “Mention me to thy lord.” But Satan made him forget to mention him to his lord: and (Joseph) lingered in prison a few (more) years.
From the two convicts “Sayyidina Yusuf (pbuh) told the one whom he anticipated would be freed, “Mention me to your master.” He asked the person to mention the king the entire episode of how he was imprisoned despite his innocence and that he was being made to suffer unnecessarily in prison.
He requested the person to do this because it was very possible that the king had no knowledge of the episode. If he were informed about it, he would learn that an innocent person had been imprisoned in his country. Although a believer endures difficulties with patience and realizes that he will be rewarded for it, there is no harm in attempting to alleviate oneself of the difficulty. It is for this reason that he told the person to inform the king of his condition.
“However, Devil caused him to forget mentioning him to his master, and Yusuf (pbuh) remained in prison for a few years.” “Ruhul Maani” mentions that he ramained there for seven or twelve years. The Arabic word “bidha” (few) referes to figures that lie between three and nine. And Allah knows best.
Madani, Muhammad. Anwar ul Bayan. (vol. 3 p. 66-67). Collection of Quran Commentaries (Tafsirs) – Islamic Web Library