Ran into lots of errors.
Additional uncaught exception thrown while handling exception.
PDOException: SQLSTATE: Integrity constraint violation: 1062 Duplicate entry
These were caused by trying to use $count++ when $count could be FALSE. Didn't work. False plus plus is still false, in PHP anyway. So it was being saved to the database as zero. And the next time the hook came up- blam.
I had to put a
debug() around each step of $count's development as a variable to see where the problem was. I also had to delete the database and xray's entry from the system table directly and repeatedly as i had broken the ability to go to the uninstall page.
mysql> delete from system where name = 'xray';
Query OK, 1 row affected (0.00 sec)
mysql> drop table xray_hook;
Query OK, 0 rows affected (0.00 sec)
The attempt to insert a row that already existed was entirely my fault, of course.
It came after getting around an error that is a little more unexpected: Drupal can invoke a module's implementation of hook_module_implements_alter() before that module's database tables are installed.