FR 8240 then FR 5356 at Madrid
Porto → Madrid → Krakow
Timetable, Madrid time
16:30FR 8240 from Porto at the gate
14:45FR 5356 to Krakow leaves the gate
22 h 15 apart on the timetable, overnight
FR 5356 leaves 22 h 15 after FR 8240 arrives on the timetable: more than half a day, so not a connection we count.