Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there)
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.

PostUpdate.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Friendica\Core\Console;
  3. use Friendica\Core\L10n;
  4. use Friendica\Core\Config;
  5. /**
  6. * Performs database post updates
  7. *
  8. * License: AGPLv3 or later, same as Friendica
  9. *
  10. * @author Tobias Diekershoff <tobias.diekershoff@gmx.net>
  11. * @author Hypolite Petovan <hypolite@mrpetovan.com>
  12. */
  13. class PostUpdate extends \Asika\SimpleConsole\Console
  14. {
  15. protected $helpOptions = ['h', 'help', '?'];
  16. protected function getHelp()
  17. {
  18. $help = <<<HELP
  19. console postupdate - Performs database post updates
  20. Usage
  21. bin/console postupdate [-h|--help|-?] [--reset <version>]
  22. Options
  23. -h|--help|-? Show help information
  24. --reset <version> Reset the post update version
  25. HELP;
  26. return $help;
  27. }
  28. protected function doExecute()
  29. {
  30. $a = \Friendica\BaseObject::getApp();
  31. if ($this->getOption($this->helpOptions)) {
  32. $this->out($this->getHelp());
  33. return 0;
  34. }
  35. $reset_version = $this->getOption('reset');
  36. if (is_bool($reset_version)) {
  37. $this->out($this->getHelp());
  38. return 0;
  39. } elseif ($reset_version) {
  40. Config::set('system', 'post_update_version', $reset_version);
  41. echo L10n::t('Post update version number has been set to %s.', $reset_version) . "\n";
  42. return 0;
  43. }
  44. if ($a->getMode()->isInstall()) {
  45. throw new \RuntimeException('Database isn\'t ready or populated yet');
  46. }
  47. echo L10n::t('Execute pending post updates.') . "\n";
  48. while (!\Friendica\Database\PostUpdate::update()) {
  49. echo '.';
  50. }
  51. echo "\n" . L10n::t('All pending post updates are done.') . "\n";
  52. return 0;
  53. }
  54. }