| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | Copyright CiviCRM LLC. All rights reserved. | |
| 5 | | | |
| 6 | | This work is published under the GNU AGPLv3 license with some | |
| 7 | | permitted exceptions and without any warranty. For full license | |
| 8 | | and copyright information, see https://civicrm.org/licensing | |
| 9 | +--------------------------------------------------------------------+ |
| 10 | */ |
| 11 | |
| 12 | namespace Civi\Core; |
| 13 | |
| 14 | use Civi\Core\Event\SystemInstallEvent; |
| 15 | |
| 16 | /** |
| 17 | * Class InstallationCanary |
| 18 | * @package Civi\Core |
| 19 | */ |
| 20 | class InstallationCanary { |
| 21 | |
| 22 | /** |
| 23 | * Check whether the install has run before. |
| 24 | * |
| 25 | * Circa v4.7.betaX, we introduced a new mechanism for tracking installation |
| 26 | * and firing a post-install event. However, it's fairly difficult to test the |
| 27 | * edge-cases directly, so this canary should fire if there are any problems |
| 28 | * in the design/implementation of the installation-tracker. |
| 29 | * |
| 30 | * This should not exist. It should be removed in a future version. |
| 31 | * |
| 32 | * @param \Civi\Core\Event\SystemInstallEvent $event |
| 33 | * @throws \CRM_Core_Exception |
| 34 | */ |
| 35 | public static function check(SystemInstallEvent $event) { |
| 36 | if (\CRM_Core_DAO::checkTableExists('civicrm_install_canary')) { |
| 37 | throw new \CRM_Core_Exception("Found installation canary. This suggests that something went wrong with tracking installation process. Please post to forum or JIRA."); |
| 38 | } |
| 39 | \Civi::log()->info('Creating canary table'); |
| 40 | \CRM_Core_DAO::executeQuery('CREATE TABLE civicrm_install_canary (id int(10) unsigned NOT NULL) ENGINE=InnoDB'); |
| 41 | } |
| 42 | |
| 43 | } |