xibosignage / xibo

Xibo Digital Signage
https://xibosignage.com
GNU Affero General Public License v3.0
566 stars 165 forks source link

Unexpected Error when Deleting Display Entry due to Orphaned Schedule record. #1706

Open DanielBW1 opened 5 years ago

DanielBW1 commented 5 years ago

CMS Version: 1.8.11

Issue: When attempting to delete a Display entry, Unexpected error was returned. Report fault revealed the following:

"SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (acc6255.schedule, CONSTRAINT schedule_ibfk_1 FOREIGN KEY (CampaignID) REFERENCES campaign (CampaignID))#0 ``/lib/Storage/PdoStorageService.php(239): PDOStatement->execute(Array)

1 ``/lib/Entity/Schedule.php(621): Xibo\Storage\PdoStorageService->update('? UPDA...', Array)

2 ``/lib/Entity/Schedule.php(489): Xibo\Entity\Schedule->edit()

3 ``/lib/Entity/DisplayGroup.php(683): Xibo\Entity\Schedule->save(Array)

4 ``/lib/Entity/Display.php(606): Xibo\Entity\DisplayGroup->delete()

5 ``/lib/Controller/Display.php(1054): Xibo\Entity\Display->delete()

6 [internal function]: Xibo\Controller\Display->delete('2')

7 ``/vendor/akrabat/rka-slim-controller/RKA/Slim.php(79): call_user_func_array(Array, Array)

8 [internal function]: RKA\Slim->RKA{closure}('2')

9 ``/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)

10 ``/vendor/slim/slim/Slim/Slim.php(1355): Slim\Route->dispatch()

11 ``/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()

12 ``/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()

13 ``/lib/Middleware/Actions.php(160): Slim\Middleware\MethodOverride->call()

14 ``/lib/Middleware/Theme.php(36): Xibo\Middleware\Actions->call()

15 ``/lib/Middleware/WebAuthentication.php(131): Xibo\Middleware\Theme->call()

16 ``/lib/Middleware/CsrfGuard.php(63): Xibo\Middleware\WebAuthentication->call()

17 ``/lib/Middleware/State.php(122): Xibo\Middleware\CsrfGuard->call()

18 ``/lib/Middleware/Storage.php(47): Xibo\Middleware\State->call()

19 ``/lib/Middleware/Xmr.php(37): Xibo\Middleware\Storage->call()

20 ``/vendor/slim/slim/Slim/Slim.php(1300): Xibo\Middleware\Xmr->call()

21 ``/web/index.php(124): Slim\Slim->run()

22 {main}"

Note: This was caused by an orphaned schedule record. The delete should detect and remove the schedule instead of trying to update it.

exalate-issue-sync[bot] commented 5 years ago

Dan Garner commented: This is not as clear cut as originally expected. The delete Display routine does already instruct the Schedule event delete to remove orphaned records, assuming they are orphaned because the act of removing this display would leave them without any display groups connected. However the error message relates to a missing Campaign, which already shouldn't be possible.

Something fishy has occurred on the CMS in question which we do not entirely understand, therefore I have put this issue on the backlog for now.