Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like OC often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use OC, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 59 | class OC { |
||
| 60 | /** |
||
| 61 | * Associative array for autoloading. classname => filename |
||
| 62 | */ |
||
| 63 | public static $CLASSPATH = array(); |
||
| 64 | /** |
||
| 65 | * The installation path for Nextcloud on the server (e.g. /srv/http/nextcloud) |
||
| 66 | */ |
||
| 67 | public static $SERVERROOT = ''; |
||
| 68 | /** |
||
| 69 | * the current request path relative to the Nextcloud root (e.g. files/index.php) |
||
| 70 | */ |
||
| 71 | private static $SUBURI = ''; |
||
| 72 | /** |
||
| 73 | * the Nextcloud root path for http requests (e.g. nextcloud/) |
||
| 74 | */ |
||
| 75 | public static $WEBROOT = ''; |
||
| 76 | /** |
||
| 77 | * The installation path array of the apps folder on the server (e.g. /srv/http/nextcloud) 'path' and |
||
| 78 | * web path in 'url' |
||
| 79 | */ |
||
| 80 | public static $APPSROOTS = array(); |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var string |
||
| 84 | */ |
||
| 85 | public static $configDir; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * requested app |
||
| 89 | */ |
||
| 90 | public static $REQUESTEDAPP = ''; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * check if Nextcloud runs in cli mode |
||
| 94 | */ |
||
| 95 | public static $CLI = false; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @var \OC\Autoloader $loader |
||
| 99 | */ |
||
| 100 | public static $loader = null; |
||
| 101 | |||
| 102 | /** @var \Composer\Autoload\ClassLoader $composerAutoloader */ |
||
| 103 | public static $composerAutoloader = null; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @var \OC\Server |
||
| 107 | */ |
||
| 108 | public static $server = null; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @var \OC\Config |
||
| 112 | */ |
||
| 113 | private static $config = null; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @throws \RuntimeException when the 3rdparty directory is missing or |
||
| 117 | * the app path list is empty or contains an invalid path |
||
| 118 | */ |
||
| 119 | public static function initPaths() { |
||
| 224 | |||
| 225 | public static function checkConfig() { |
||
| 257 | |||
| 258 | public static function checkInstalled() { |
||
| 273 | |||
| 274 | public static function checkMaintenanceMode() { |
||
| 275 | // Allow ajax update script to execute without being stopped |
||
| 276 | if (\OC::$server->getSystemConfig()->getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') { |
||
| 277 | // send http status 503 |
||
| 278 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
||
| 279 | header('Status: 503 Service Temporarily Unavailable'); |
||
| 280 | header('Retry-After: 120'); |
||
| 281 | |||
| 282 | // render error page |
||
| 283 | $template = new OC_Template('', 'update.user', 'guest'); |
||
| 284 | OC_Util::addScript('maintenance-check'); |
||
| 285 | $template->printPage(); |
||
| 286 | die(); |
||
| 287 | } |
||
| 288 | } |
||
| 289 | |||
| 290 | public static function checkSingleUserMode($lockIfNoUserLoggedIn = false) { |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Checks if the version requires an update and shows |
||
| 318 | * @param bool $showTemplate Whether an update screen should get shown |
||
| 319 | * @return bool|void |
||
| 320 | */ |
||
| 321 | public static function checkUpgrade($showTemplate = true) { |
||
| 333 | |||
| 334 | /** |
||
| 335 | * Prints the upgrade page |
||
| 336 | */ |
||
| 337 | private static function printUpgradePage() { |
||
| 395 | |||
| 396 | public static function initSession() { |
||
| 442 | |||
| 443 | /** |
||
| 444 | * @return string |
||
| 445 | */ |
||
| 446 | private static function getSessionLifeTime() { |
||
| 449 | |||
| 450 | public static function loadAppClassPaths() { |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Try to set some values to the required Nextcloud default |
||
| 466 | */ |
||
| 467 | public static function setRequiredIniValues() { |
||
| 471 | |||
| 472 | public static function init() { |
||
| 473 | // calculate the root directories |
||
| 474 | OC::$SERVERROOT = str_replace("\\", '/', substr(__DIR__, 0, -4)); |
||
| 475 | |||
| 476 | // register autoloader |
||
| 477 | $loaderStart = microtime(true); |
||
| 478 | require_once __DIR__ . '/autoloader.php'; |
||
| 479 | self::$loader = new \OC\Autoloader([ |
||
| 480 | OC::$SERVERROOT . '/lib/private/legacy', |
||
| 481 | ]); |
||
| 482 | if (defined('PHPUNIT_RUN')) { |
||
| 483 | self::$loader->addValidRoot(OC::$SERVERROOT . '/tests'); |
||
| 484 | } |
||
| 485 | spl_autoload_register(array(self::$loader, 'load')); |
||
| 486 | $loaderEnd = microtime(true); |
||
| 487 | |||
| 488 | self::$CLI = (php_sapi_name() == 'cli'); |
||
| 489 | |||
| 490 | // Add default composer PSR-4 autoloader |
||
| 491 | self::$composerAutoloader = require_once OC::$SERVERROOT . '/lib/composer/autoload.php'; |
||
| 492 | |||
| 493 | try { |
||
| 494 | self::initPaths(); |
||
| 495 | // setup 3rdparty autoloader |
||
| 496 | $vendorAutoLoad = OC::$SERVERROOT. '/3rdparty/autoload.php'; |
||
| 497 | if (!file_exists($vendorAutoLoad)) { |
||
| 498 | throw new \RuntimeException('Composer autoloader not found, unable to continue. Check the folder "3rdparty". Running "git submodule update --init" will initialize the git submodule that handles the subfolder "3rdparty".'); |
||
| 499 | } |
||
| 500 | require_once $vendorAutoLoad; |
||
| 501 | |||
| 502 | } catch (\RuntimeException $e) { |
||
| 503 | if (!self::$CLI) { |
||
| 504 | $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
||
| 505 | $protocol = in_array($claimedProtocol, ['HTTP/1.0', 'HTTP/1.1', 'HTTP/2']) ? $claimedProtocol : 'HTTP/1.1'; |
||
| 506 | header($protocol . ' ' . OC_Response::STATUS_SERVICE_UNAVAILABLE); |
||
| 507 | } |
||
| 508 | // we can't use the template error page here, because this needs the |
||
| 509 | // DI container which isn't available yet |
||
| 510 | print($e->getMessage()); |
||
| 511 | exit(); |
||
| 512 | } |
||
| 513 | |||
| 514 | // setup the basic server |
||
| 515 | self::$server = new \OC\Server(\OC::$WEBROOT, self::$config); |
||
| 516 | \OC::$server->getEventLogger()->log('autoloader', 'Autoloader', $loaderStart, $loaderEnd); |
||
| 517 | \OC::$server->getEventLogger()->start('boot', 'Initialize'); |
||
| 518 | |||
| 519 | // Don't display errors and log them |
||
| 520 | error_reporting(E_ALL | E_STRICT); |
||
| 521 | @ini_set('display_errors', 0); |
||
| 522 | @ini_set('log_errors', 1); |
||
| 523 | |||
| 524 | date_default_timezone_set('UTC'); |
||
| 525 | |||
| 526 | //try to configure php to enable big file uploads. |
||
| 527 | //this doesn´t work always depending on the webserver and php configuration. |
||
| 528 | //Let´s try to overwrite some defaults anyway |
||
| 529 | |||
| 530 | //try to set the maximum execution time to 60min |
||
| 531 | @set_time_limit(3600); |
||
| 532 | @ini_set('max_execution_time', 3600); |
||
| 533 | @ini_set('max_input_time', 3600); |
||
| 534 | |||
| 535 | //try to set the maximum filesize to 10G |
||
| 536 | @ini_set('upload_max_filesize', '10G'); |
||
| 537 | @ini_set('post_max_size', '10G'); |
||
| 538 | @ini_set('file_uploads', '50'); |
||
| 539 | |||
| 540 | self::setRequiredIniValues(); |
||
| 541 | self::handleAuthHeaders(); |
||
| 542 | self::registerAutoloaderCache(); |
||
| 543 | |||
| 544 | // initialize intl fallback is necessary |
||
| 545 | \Patchwork\Utf8\Bootup::initIntl(); |
||
| 546 | OC_Util::isSetLocaleWorking(); |
||
| 547 | |||
| 548 | if (!defined('PHPUNIT_RUN')) { |
||
| 549 | OC\Log\ErrorHandler::setLogger(\OC::$server->getLogger()); |
||
| 550 | $debug = \OC::$server->getConfig()->getSystemValue('debug', false); |
||
| 551 | OC\Log\ErrorHandler::register($debug); |
||
| 552 | } |
||
| 553 | |||
| 554 | // register the stream wrappers |
||
| 555 | stream_wrapper_register('fakedir', 'OC\Files\Stream\Dir'); |
||
| 556 | stream_wrapper_register('static', 'OC\Files\Stream\StaticStream'); |
||
| 557 | stream_wrapper_register('close', 'OC\Files\Stream\Close'); |
||
| 558 | stream_wrapper_register('quota', 'OC\Files\Stream\Quota'); |
||
| 559 | stream_wrapper_register('oc', 'OC\Files\Stream\OC'); |
||
| 560 | |||
| 561 | \OC::$server->getEventLogger()->start('init_session', 'Initialize session'); |
||
| 562 | OC_App::loadApps(array('session')); |
||
| 563 | if (!self::$CLI) { |
||
| 564 | self::initSession(); |
||
| 565 | } |
||
| 566 | \OC::$server->getEventLogger()->end('init_session'); |
||
| 567 | self::checkConfig(); |
||
| 568 | self::checkInstalled(); |
||
| 569 | |||
| 570 | OC_Response::addSecurityHeaders(); |
||
| 571 | if(self::$server->getRequest()->getServerProtocol() === 'https') { |
||
| 572 | ini_set('session.cookie_secure', true); |
||
| 573 | } |
||
| 574 | |||
| 575 | if (!defined('OC_CONSOLE')) { |
||
| 576 | $errors = OC_Util::checkServer(\OC::$server->getConfig()); |
||
| 577 | if (count($errors) > 0) { |
||
| 578 | if (self::$CLI) { |
||
| 579 | // Convert l10n string into regular string for usage in database |
||
| 580 | $staticErrors = []; |
||
| 581 | foreach ($errors as $error) { |
||
| 582 | echo $error['error'] . "\n"; |
||
| 583 | echo $error['hint'] . "\n\n"; |
||
| 584 | $staticErrors[] = [ |
||
| 585 | 'error' => (string)$error['error'], |
||
| 586 | 'hint' => (string)$error['hint'], |
||
| 587 | ]; |
||
| 588 | } |
||
| 589 | |||
| 590 | try { |
||
| 591 | \OC::$server->getConfig()->setAppValue('core', 'cronErrors', json_encode($staticErrors)); |
||
| 592 | } catch (\Exception $e) { |
||
| 593 | echo('Writing to database failed'); |
||
| 594 | } |
||
| 595 | exit(1); |
||
| 596 | } else { |
||
| 597 | OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE); |
||
| 598 | OC_Template::printGuestPage('', 'error', array('errors' => $errors)); |
||
| 599 | exit; |
||
| 600 | } |
||
| 601 | View Code Duplication | } elseif (self::$CLI && \OC::$server->getConfig()->getSystemValue('installed', false)) { |
|
| 602 | \OC::$server->getConfig()->deleteAppValue('core', 'cronErrors'); |
||
| 603 | } |
||
| 604 | } |
||
| 605 | //try to set the session lifetime |
||
| 606 | $sessionLifeTime = self::getSessionLifeTime(); |
||
| 607 | @ini_set('gc_maxlifetime', (string)$sessionLifeTime); |
||
| 608 | |||
| 609 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 610 | |||
| 611 | // User and Groups |
||
| 612 | if (!$systemConfig->getValue("installed", false)) { |
||
| 613 | self::$server->getSession()->set('user_id', ''); |
||
| 614 | } |
||
| 615 | |||
| 616 | OC_User::useBackend(new \OC\User\Database()); |
||
| 617 | OC_Group::useBackend(new \OC\Group\Database()); |
||
| 618 | |||
| 619 | // Subscribe to the hook |
||
| 620 | \OCP\Util::connectHook( |
||
| 621 | '\OCA\Files_Sharing\API\Server2Server', |
||
| 622 | 'preLoginNameUsedAsUserName', |
||
| 623 | '\OC\User\Database', |
||
| 624 | 'preLoginNameUsedAsUserName' |
||
| 625 | ); |
||
| 626 | |||
| 627 | //setup extra user backends |
||
| 628 | if (!self::checkUpgrade(false)) { |
||
| 629 | OC_User::setupBackends(); |
||
| 630 | } else { |
||
| 631 | // Run upgrades in incognito mode |
||
| 632 | OC_User::setIncognitoMode(true); |
||
| 633 | } |
||
| 634 | |||
| 635 | self::registerCacheHooks(); |
||
| 636 | self::registerFilesystemHooks(); |
||
| 637 | if ($systemConfig->getValue('enable_previews', true)) { |
||
| 638 | self::registerPreviewHooks(); |
||
| 639 | } |
||
| 640 | self::registerShareHooks(); |
||
| 641 | self::registerLogRotate(); |
||
| 642 | self::registerEncryptionWrapper(); |
||
| 643 | self::registerEncryptionHooks(); |
||
| 644 | |||
| 645 | //make sure temporary files are cleaned up |
||
| 646 | $tmpManager = \OC::$server->getTempManager(); |
||
| 647 | register_shutdown_function(array($tmpManager, 'clean')); |
||
| 648 | $lockProvider = \OC::$server->getLockingProvider(); |
||
| 649 | register_shutdown_function(array($lockProvider, 'releaseAll')); |
||
| 650 | |||
| 651 | // Check whether the sample configuration has been copied |
||
| 652 | if($systemConfig->getValue('copied_sample_config', false)) { |
||
| 653 | $l = \OC::$server->getL10N('lib'); |
||
| 654 | header('HTTP/1.1 503 Service Temporarily Unavailable'); |
||
| 655 | header('Status: 503 Service Temporarily Unavailable'); |
||
| 656 | OC_Template::printErrorPage( |
||
| 657 | $l->t('Sample configuration detected'), |
||
| 658 | $l->t('It has been detected that the sample configuration has been copied. This can break your installation and is unsupported. Please read the documentation before performing changes on config.php') |
||
| 659 | ); |
||
| 660 | return; |
||
| 661 | } |
||
| 662 | |||
| 663 | $request = \OC::$server->getRequest(); |
||
| 664 | $host = $request->getInsecureServerHost(); |
||
| 665 | /** |
||
| 666 | * if the host passed in headers isn't trusted |
||
| 667 | * FIXME: Should not be in here at all :see_no_evil: |
||
| 668 | */ |
||
| 669 | if (!OC::$CLI |
||
| 670 | // overwritehost is always trusted, workaround to not have to make |
||
| 671 | // \OC\AppFramework\Http\Request::getOverwriteHost public |
||
| 672 | && self::$server->getConfig()->getSystemValue('overwritehost') === '' |
||
| 673 | && !\OC::$server->getTrustedDomainHelper()->isTrustedDomain($host) |
||
| 674 | && self::$server->getConfig()->getSystemValue('installed', false) |
||
| 675 | ) { |
||
| 676 | header('HTTP/1.1 400 Bad Request'); |
||
| 677 | header('Status: 400 Bad Request'); |
||
| 678 | |||
| 679 | \OC::$server->getLogger()->warning( |
||
| 680 | 'Trusted domain error. "{remoteAddress}" tried to access using "{host}" as host.', |
||
| 681 | [ |
||
| 682 | 'app' => 'core', |
||
| 683 | 'remoteAddress' => $request->getRemoteAddress(), |
||
| 684 | 'host' => $host, |
||
| 685 | ] |
||
| 686 | ); |
||
| 687 | |||
| 688 | $tmpl = new OCP\Template('core', 'untrustedDomain', 'guest'); |
||
| 689 | $tmpl->assign('domain', $host); |
||
| 690 | $tmpl->printPage(); |
||
| 691 | |||
| 692 | exit(); |
||
| 693 | } |
||
| 694 | \OC::$server->getEventLogger()->end('boot'); |
||
| 695 | } |
||
| 696 | |||
| 697 | /** |
||
| 698 | * register hooks for the cache |
||
| 699 | */ |
||
| 700 | public static function registerCacheHooks() { |
||
| 721 | |||
| 722 | private static function registerEncryptionWrapper() { |
||
| 726 | |||
| 727 | private static function registerEncryptionHooks() { |
||
| 736 | |||
| 737 | /** |
||
| 738 | * register hooks for the cache |
||
| 739 | */ |
||
| 740 | public static function registerLogRotate() { |
||
| 741 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 742 | if ($systemConfig->getValue('installed', false) && $systemConfig->getValue('log_rotate_size', false) && !self::checkUpgrade(false)) { |
||
| 743 | //don't try to do this before we are properly setup |
||
| 744 | //use custom logfile path if defined, otherwise use default of nextcloud.log in data directory |
||
| 745 | \OCP\BackgroundJob::registerJob('OC\Log\Rotate', $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', OC::$SERVERROOT . '/data') . '/nextcloud.log')); |
||
| 746 | } |
||
| 747 | } |
||
| 748 | |||
| 749 | /** |
||
| 750 | * register hooks for the filesystem |
||
| 751 | */ |
||
| 752 | public static function registerFilesystemHooks() { |
||
| 757 | |||
| 758 | /** |
||
| 759 | * register hooks for previews |
||
| 760 | */ |
||
| 761 | public static function registerPreviewHooks() { |
||
| 771 | |||
| 772 | /** |
||
| 773 | * register hooks for sharing |
||
| 774 | */ |
||
| 775 | public static function registerShareHooks() { |
||
| 782 | |||
| 783 | protected static function registerAutoloaderCache() { |
||
| 799 | |||
| 800 | /** |
||
| 801 | * Handle the request |
||
| 802 | */ |
||
| 803 | public static function handleRequest() { |
||
| 804 | |||
| 805 | \OC::$server->getEventLogger()->start('handle_request', 'Handle request'); |
||
| 806 | $systemConfig = \OC::$server->getSystemConfig(); |
||
| 807 | // load all the classpaths from the enabled apps so they are available |
||
| 808 | // in the routing files of each app |
||
| 809 | OC::loadAppClassPaths(); |
||
| 810 | |||
| 811 | // Check if Nextcloud is installed or in maintenance (update) mode |
||
| 812 | if (!$systemConfig->getValue('installed', false)) { |
||
| 813 | \OC::$server->getSession()->clear(); |
||
| 814 | $setupHelper = new OC\Setup(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), |
||
| 815 | \OC::$server->getL10N('lib'), new \OC_Defaults(), \OC::$server->getLogger(), |
||
| 816 | \OC::$server->getSecureRandom()); |
||
| 817 | $controller = new OC\Core\Controller\SetupController($setupHelper); |
||
| 818 | $controller->run($_POST); |
||
| 819 | exit(); |
||
| 820 | } |
||
| 821 | |||
| 822 | $request = \OC::$server->getRequest(); |
||
| 823 | $requestPath = $request->getRawPathInfo(); |
||
| 824 | if (substr($requestPath, -3) !== '.js') { // we need these files during the upgrade |
||
| 825 | self::checkMaintenanceMode(); |
||
| 826 | self::checkUpgrade(); |
||
| 827 | } |
||
| 828 | |||
| 829 | // emergency app disabling |
||
| 830 | if ($requestPath === '/disableapp' |
||
| 831 | && $request->getMethod() === 'POST' |
||
| 832 | && ((string)$request->getParam('appid')) !== '' |
||
| 833 | ) { |
||
| 834 | \OCP\JSON::callCheck(); |
||
| 835 | \OCP\JSON::checkAdminUser(); |
||
| 836 | $appId = (string)$request->getParam('appid'); |
||
| 837 | $appId = \OC_App::cleanAppId($appId); |
||
| 838 | |||
| 839 | \OC_App::disable($appId); |
||
| 840 | \OC_JSON::success(); |
||
| 841 | exit(); |
||
| 842 | } |
||
| 843 | |||
| 844 | // Always load authentication apps |
||
| 845 | OC_App::loadApps(['authentication']); |
||
| 846 | |||
| 847 | // Load minimum set of apps |
||
| 848 | if (!self::checkUpgrade(false) |
||
| 849 | && !$systemConfig->getValue('maintenance', false)) { |
||
| 850 | // For logged-in users: Load everything |
||
| 851 | if(OC_User::isLoggedIn()) { |
||
| 852 | OC_App::loadApps(); |
||
| 853 | } else { |
||
| 854 | // For guests: Load only filesystem and logging |
||
| 855 | OC_App::loadApps(array('filesystem', 'logging')); |
||
| 856 | self::handleLogin($request); |
||
| 857 | } |
||
| 858 | } |
||
| 859 | |||
| 860 | if (!self::$CLI) { |
||
| 861 | try { |
||
| 862 | if (!$systemConfig->getValue('maintenance', false) && !self::checkUpgrade(false)) { |
||
| 863 | OC_App::loadApps(array('filesystem', 'logging')); |
||
| 864 | OC_App::loadApps(); |
||
| 865 | } |
||
| 866 | self::checkSingleUserMode(); |
||
| 867 | OC_Util::setupFS(); |
||
| 868 | OC::$server->getRouter()->match(\OC::$server->getRequest()->getRawPathInfo()); |
||
| 869 | return; |
||
| 870 | } catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) { |
||
| 871 | //header('HTTP/1.0 404 Not Found'); |
||
| 872 | } catch (Symfony\Component\Routing\Exception\MethodNotAllowedException $e) { |
||
| 873 | OC_Response::setStatus(405); |
||
| 874 | return; |
||
| 875 | } |
||
| 876 | } |
||
| 877 | |||
| 878 | // Handle WebDAV |
||
| 879 | if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND') { |
||
| 880 | // not allowed any more to prevent people |
||
| 881 | // mounting this root directly. |
||
| 882 | // Users need to mount remote.php/webdav instead. |
||
| 883 | header('HTTP/1.1 405 Method Not Allowed'); |
||
| 884 | header('Status: 405 Method Not Allowed'); |
||
| 885 | return; |
||
| 886 | } |
||
| 887 | |||
| 888 | // Someone is logged in |
||
| 889 | if (OC_User::isLoggedIn()) { |
||
| 890 | OC_App::loadApps(); |
||
| 891 | OC_User::setupBackends(); |
||
| 892 | OC_Util::setupFS(); |
||
| 893 | // FIXME |
||
| 894 | // Redirect to default application |
||
| 895 | OC_Util::redirectToDefaultPage(); |
||
| 896 | } else { |
||
| 897 | // Not handled and not logged in |
||
| 898 | header('Location: '.\OC::$server->getURLGenerator()->linkToRouteAbsolute('core.login.showLoginForm')); |
||
| 899 | } |
||
| 900 | } |
||
| 901 | |||
| 902 | /** |
||
| 903 | * Check login: apache auth, auth token, basic auth |
||
| 904 | * |
||
| 905 | * @param OCP\IRequest $request |
||
| 906 | * @return boolean |
||
| 907 | */ |
||
| 908 | private static function handleLogin(OCP\IRequest $request) { |
||
| 921 | |||
| 922 | protected static function handleAuthHeaders() { |
||
| 942 | } |
||
| 943 | |||
| 944 | OC::init(); |
||
| 945 |
If you suppress an error, we recommend checking for the error condition explicitly: