WebInstallerUpgrade.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. * http://www.gnu.org/copyleft/gpl.html
  17. *
  18. * @file
  19. * @ingroup Deployment
  20. */
  21. class WebInstallerUpgrade extends WebInstallerPage {
  22. /**
  23. * @return bool Always true.
  24. */
  25. public function isSlow() {
  26. return true;
  27. }
  28. /**
  29. * @return string|null
  30. */
  31. public function execute() {
  32. if ( $this->getVar( '_UpgradeDone' ) ) {
  33. // Allow regeneration of LocalSettings.php, unless we are working
  34. // from a pre-existing LocalSettings.php file and we want to avoid
  35. // leaking its contents
  36. if ( $this->parent->request->wasPosted() && !$this->getVar( '_ExistingDBSettings' ) ) {
  37. // Done message acknowledged
  38. return 'continue';
  39. }
  40. // Back button click
  41. // Show the done message again
  42. // Make them click back again if they want to do the upgrade again
  43. $this->showDoneMessage();
  44. return 'output';
  45. }
  46. // wgDBtype is generally valid here because otherwise the previous page
  47. // (connect) wouldn't have declared its happiness
  48. $type = $this->getVar( 'wgDBtype' );
  49. $installer = $this->parent->getDBInstaller( $type );
  50. if ( !$installer->needsUpgrade() ) {
  51. return 'skip';
  52. }
  53. if ( $this->parent->request->wasPosted() ) {
  54. $installer->preUpgrade();
  55. $this->startLiveBox();
  56. $result = $installer->doUpgrade();
  57. $this->endLiveBox();
  58. if ( $result ) {
  59. // If they're going to possibly regenerate LocalSettings, we
  60. // need to create the upgrade/secret keys. T28481
  61. if ( !$this->getVar( '_ExistingDBSettings' ) ) {
  62. $this->parent->generateKeys();
  63. }
  64. $this->setVar( '_UpgradeDone', true );
  65. $this->showDoneMessage();
  66. } else {
  67. $this->startForm();
  68. $this->parent->showError( 'config-upgrade-error' );
  69. $this->endForm();
  70. }
  71. return 'output';
  72. }
  73. $this->startForm();
  74. $this->addHTML( $this->parent->getInfoBox(
  75. wfMessage( 'config-can-upgrade', $GLOBALS['wgVersion'] )->plain() ) );
  76. $this->endForm();
  77. return null;
  78. }
  79. public function showDoneMessage() {
  80. $this->startForm();
  81. $regenerate = !$this->getVar( '_ExistingDBSettings' );
  82. if ( $regenerate ) {
  83. $msg = 'config-upgrade-done';
  84. } else {
  85. $msg = 'config-upgrade-done-no-regenerate';
  86. }
  87. $this->parent->disableLinkPopups();
  88. $this->addHTML(
  89. $this->parent->getInfoBox(
  90. wfMessage( $msg,
  91. $this->getVar( 'wgServer' ) .
  92. $this->getVar( 'wgScriptPath' ) . '/index.php'
  93. )->plain(), 'tick-32.png'
  94. )
  95. );
  96. $this->parent->restoreLinkPopups();
  97. $this->endForm( $regenerate ? 'regenerate' : false, false );
  98. }
  99. }