Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Updates.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Piwik - free/libre analytics platform
  4. *
  5. * @link http://piwik.org
  6. * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  7. *
  8. */
  9. namespace Piwik;
  10. /**
  11. * Abstract class for update scripts
  12. *
  13. * @example core/Updates/0.4.2.php
  14. */
  15. abstract class Updates
  16. {
  17. /**
  18. * Return SQL to be executed in this update
  19. *
  20. * @return array(
  21. * 'ALTER .... ' => '1234', // if the query fails, it will be ignored if the error code is 1234
  22. * 'ALTER .... ' => false, // if an error occurs, the update will stop and fail
  23. * // and user will have to manually run the query
  24. * )
  25. */
  26. static function getSql()
  27. {
  28. return array();
  29. }
  30. /**
  31. * Incremental version update
  32. */
  33. static function update()
  34. {
  35. }
  36. /**
  37. * Tell the updater that this is a major update.
  38. * Leads to a more visible notice.
  39. *
  40. * NOTE to release manager: Remember to mention in the Changelog
  41. * that this update contains major DB upgrades and will take some time!
  42. *
  43. * @return bool
  44. */
  45. static function isMajorUpdate()
  46. {
  47. return false;
  48. }
  49. /**
  50. * Helper method to enable maintenance mode during large updates
  51. */
  52. static function enableMaintenanceMode()
  53. {
  54. $config = Config::getInstance();
  55. $config->init();
  56. $tracker = $config->Tracker;
  57. $tracker['record_statistics'] = 0;
  58. $config->Tracker = $tracker;
  59. $general = $config->General;
  60. $general['maintenance_mode'] = 1;
  61. $config->General = $general;
  62. $config->forceSave();
  63. }
  64. /**
  65. * Helper method to disable maintenance mode after large updates
  66. */
  67. static function disableMaintenanceMode()
  68. {
  69. $config = Config::getInstance();
  70. $config->init();
  71. $tracker = $config->Tracker;
  72. $tracker['record_statistics'] = 1;
  73. $config->Tracker = $tracker;
  74. $general = $config->General;
  75. $general['maintenance_mode'] = 0;
  76. $config->General = $general;
  77. $config->forceSave();
  78. }
  79. public static function deletePluginFromConfigFile($pluginToDelete)
  80. {
  81. $config = Config::getInstance();
  82. $config->init();
  83. if (isset($config->Plugins['Plugins'])) {
  84. $plugins = $config->Plugins['Plugins'];
  85. if (($key = array_search($pluginToDelete, $plugins)) !== false) {
  86. unset($plugins[$key]);
  87. }
  88. $config->Plugins['Plugins'] = $plugins;
  89. $pluginsInstalled = $config->PluginsInstalled['PluginsInstalled'];
  90. if (($key = array_search($pluginToDelete, $pluginsInstalled)) !== false) {
  91. unset($pluginsInstalled[$key]);
  92. }
  93. $config->PluginsInstalled = array('PluginsInstalled' => $pluginsInstalled);
  94. $config->forceSave();
  95. }
  96. }
  97. }