StephanHoyer/Aoe_Static — pull request #14 by quafzi (2014-09-04 08:06:46+00:00)
Title: Use DELETE instead of TRUNCATE to flush cache tables

I use aoe_static and aoe_cleaner in the same shop and got an hourly cron exception mail, complaining about that:

exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (`databasename`.`aoe_static_urltag`, CONSTRAINT `FK_AOE_STATIC_URLTAG_URL_ID_AOE_STATIC_URL_URL_ID` FOREIGN KEY (`url_id`) REFERENCES `databasename`.`aoe_static_url` (`url_id`))' in /html/production/current/lib/Zend/Db/Statement/Pdo.php:228.

I know `aoe_static_url`, `aoe_static_tag`, and `aoe_static_urltag` to be InnoDB tables, so I had a look at MySQL docs, that confirmed, that `TRUNCATE` on `aoe_static_urltag` should fall back to a line-by-line `DELETE`, while deleting foreign-key rows from `aoe_static_tag` and `aoe_static_url` as well (thanks to `ON DELETE CASCADE` in `aoe_static_urltag`.

Actually, this did not work as expected, so I got the exception mentioned above.

So I changed `TRUNCATE` to `DELETE FROM` and it works now like a charm. If you have any idea, why `TRUNCATE` did not work, let me please know about that.