Cannot save an episode with the same name as a previous one
Describe the bug
After deleting an episode, it is impossible to recreate another one with the same name.
Steps to reproduce
- Delete an episode
- Create a new episode using the same name on
./cp-admin/podcasts/1/episodes/new
- Hit the save button
- Snag
Expected behavior
The episode should be saved, or the system should warn the user that the episode already exists.
Actual behavior
The deleted episode has been soft deleted. So, it is kept in the database and the new episode has the same slug as the old one. The slug field having a unique constraint, it breaks.
Relevant logs and/or screenshots
mysqli_sql_exception #1062
Duplicate entry '2-episode-i' for key 'cp_episodes.podcast_id_slug'
SYSTEMPATH/Database/MySQLi/Connection.php at line 329
322 if ($res = $this->connID->store_result())
323 {
324 $res->free();
325 }
326 }
327 try
328 {
329 return $this->connID->query($this->prepQuery($sql));
330 }
331 catch (mysqli_sql_exception $e)
332 {
333 log_message('error', $e->getMessage());
334
335 if ($this->DBDebug)
336 {
Context
- Castopod: alpha.51
- OS: Mac OS 10.13.6
- Browser: firefox 87.0
- Web server: OVH mutu / sql 5.2
Possible fixes
[If you can, link to the line of code that might be responsible for the problem]
Edited by Yassine Doghri