@@ -337,27 +337,49 @@ 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+ $ tooBig = false ;
343+ if (!$ disableWebUpdater ) {
344+ // count users
345+ $ stats = \OC ::$ server ->getUserManager ()->countUsers ();
346+ $ totalUsers = array_sum ($ stats );
347+ $ tooBig = ($ totalUsers > 50 );
348+ }
349+ if ($ disableWebUpdater || $ tooBig ) {
350+ // send http status 503
351+ header ('HTTP/1.1 503 Service Temporarily Unavailable ' );
352+ header ('Status: 503 Service Temporarily Unavailable ' );
353+ header ('Retry-After: 120 ' );
354+
355+ // render error page
356+ $ template = new OC_Template ('' , 'update.use-cli ' , 'guest ' );
357+ $ template ->assign ('productName ' , 'ownCloud ' ); // for now
358+ $ template ->assign ('version ' , OC_Util::getVersionString ());
359+ $ template ->assign ('tooBig ' , $ tooBig );
360+
361+ $ template ->printPage ();
362+ die ();
363+ }
364+
365+ // check whether this is a core update or apps update
366+ $ installedVersion = $ systemConfig ->getValue ('version ' , '0.0.0 ' );
367+ $ currentVersion = implode ('. ' , \OCP \Util::getVersion ());
368+
369+ // if not a core upgrade, then it's apps upgrade
370+ $ isAppsOnlyUpgrade = (version_compare ($ currentVersion , $ installedVersion , '= ' ));
371+
340372 $ oldTheme = $ systemConfig ->getValue ('theme ' );
341373 $ systemConfig ->setValue ('theme ' , '' );
342374 \OCP \Util::addScript ('config ' ); // needed for web root
343375 \OCP \Util::addScript ('update ' );
344376 \OCP \Util::addStyle ('update ' );
345377
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-
350378 $ appManager = \OC ::$ server ->getAppManager ();
351379
352380 $ tmpl = new OC_Template ('' , 'update.admin ' , 'guest ' );
353381 $ 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- }
382+ $ tmpl ->assign ('isAppsOnlyUpgrade ' , $ isAppsOnlyUpgrade );
361383
362384 // get third party apps
363385 $ ocVersion = \OCP \Util::getVersion ();
@@ -423,7 +445,7 @@ private static function getSessionLifeTime() {
423445 }
424446
425447 public static function loadAppClassPaths () {
426- foreach (OC_APP ::getEnabledApps () as $ app ) {
448+ foreach (OC_App ::getEnabledApps () as $ app ) {
427449 $ appPath = OC_App::getAppPath ($ app );
428450 if ($ appPath === false ) {
429451 continue ;
0 commit comments