@@ -337,27 +337,47 @@ public static function checkUpgrade($showTemplate = true) {
337337 */
338338 private static function printUpgradePage () {
339339 $ systemConfig = \OC ::$ server ->getSystemConfig ();
340+
341+ $ disableWebUpdater = $ systemConfig ->getValue ('upgrade.disable-web ' , false );
342+ if (!$ disableWebUpdater ) {
343+ // count users
344+ $ stats = \OC ::$ server ->getUserManager ()->countUsers ();
345+ $ totalUsers = array_sum ($ stats );
346+ $ disableWebUpdater = ($ totalUsers > 50 );
347+ }
348+ if ($ disableWebUpdater ) {
349+ // send http status 503
350+ header ('HTTP/1.1 503 Service Temporarily Unavailable ' );
351+ header ('Status: 503 Service Temporarily Unavailable ' );
352+ header ('Retry-After: 120 ' );
353+
354+ // render error page
355+ $ template = new OC_Template ('' , 'update.use-cli ' , 'guest ' );
356+ $ template ->assign ('productName ' , 'ownCloud ' ); // for now
357+ $ template ->assign ('version ' , OC_Util::getVersionString ());
358+
359+ $ template ->printPage ();
360+ die ();
361+ }
362+
363+ // check whether this is a core update or apps update
364+ $ installedVersion = $ systemConfig ->getValue ('version ' , '0.0.0 ' );
365+ $ currentVersion = implode ('. ' , \OCP \Util::getVersion ());
366+
367+ // if not a core upgrade, then it's apps upgrade
368+ $ isAppsOnlyUpgrade = (version_compare ($ currentVersion , $ installedVersion , '= ' ));
369+
340370 $ oldTheme = $ systemConfig ->getValue ('theme ' );
341371 $ systemConfig ->setValue ('theme ' , '' );
342372 \OCP \Util::addScript ('config ' ); // needed for web root
343373 \OCP \Util::addScript ('update ' );
344374 \OCP \Util::addStyle ('update ' );
345375
346- // check whether this is a core update or apps update
347- $ installedVersion = $ systemConfig ->getValue ('version ' , '0.0.0 ' );
348- $ currentVersion = implode ('. ' , \OCP \Util::getVersion ());
349-
350376 $ appManager = \OC ::$ server ->getAppManager ();
351377
352378 $ tmpl = new OC_Template ('' , 'update.admin ' , 'guest ' );
353379 $ tmpl ->assign ('version ' , OC_Util::getVersionString ());
354-
355- // if not a core upgrade, then it's apps upgrade
356- if (version_compare ($ currentVersion , $ installedVersion , '= ' )) {
357- $ tmpl ->assign ('isAppsOnlyUpgrade ' , true );
358- } else {
359- $ tmpl ->assign ('isAppsOnlyUpgrade ' , false );
360- }
380+ $ tmpl ->assign ('isAppsOnlyUpgrade ' , $ isAppsOnlyUpgrade );
361381
362382 // get third party apps
363383 $ ocVersion = \OCP \Util::getVersion ();
@@ -423,7 +443,7 @@ private static function getSessionLifeTime() {
423443 }
424444
425445 public static function loadAppClassPaths () {
426- foreach (OC_APP ::getEnabledApps () as $ app ) {
446+ foreach (OC_App ::getEnabledApps () as $ app ) {
427447 $ appPath = OC_App::getAppPath ($ app );
428448 if ($ appPath === false ) {
429449 continue ;
0 commit comments