* Loads the options file, automatically created if not exists.
*/
protected function loadOptions()
+ {
+ $this->defineLegacyOptions();
+
+ $filename = WCF_DIR . 'options.inc.php';
+
+ // create options file if doesn't exist
+ if (!\file_exists($filename) || \filemtime($filename) <= 1) {
+ OptionEditor::rebuild();
+ }
+ require($filename);
+
+ // check if option file is complete and writable
+ if (PACKAGE_ID) {
+ if (!\is_writable($filename)) {
+ FileUtil::makeWritable($filename);
+
+ if (!\is_writable($filename)) {
+ throw new SystemException("The option file '" . $filename . "' is not writable.");
+ }
+ }
+
+ // check if a previous write operation was incomplete and force rebuilding
+ if (!\defined('WCF_OPTION_INC_PHP_SUCCESS')) {
+ OptionEditor::rebuild();
+
+ require($filename);
+ }
+
+ if (ENABLE_DEBUG_MODE) {
+ self::$dbObj->enableDebugMode();
+ }
+ }
+ }
+
+ /**
+ * Defines constants for obsolete options, which were removed.
+ *
+ * @since 5.4
+ */
+ protected function defineLegacyOptions(): void
{
// The attachment module is always enabled since 5.2.
// https://github.com/WoltLab/WCF/issues/2531
// Cover photos are always enabled since 5.4.
// https://github.com/WoltLab/WCF/issues/3902
\define('MODULE_USER_COVER_PHOTO', 1);
-
- $filename = WCF_DIR . 'options.inc.php';
-
- // create options file if doesn't exist
- if (!\file_exists($filename) || \filemtime($filename) <= 1) {
- OptionEditor::rebuild();
- }
- require($filename);
-
- // check if option file is complete and writable
- if (PACKAGE_ID) {
- if (!\is_writable($filename)) {
- FileUtil::makeWritable($filename);
-
- if (!\is_writable($filename)) {
- throw new SystemException("The option file '" . $filename . "' is not writable.");
- }
- }
-
- // check if a previous write operation was incomplete and force rebuilding
- if (!\defined('WCF_OPTION_INC_PHP_SUCCESS')) {
- OptionEditor::rebuild();
-
- require($filename);
- }
-
- if (ENABLE_DEBUG_MODE) {
- self::$dbObj->enableDebugMode();
- }
- }
}
/**
*/
public static function getApplicationObject(Application $application)
{
- if (isset(self::$applicationObjects[$application->packageID])) {
- return self::$applicationObjects[$application->packageID];
- }
+ return self::$applicationObjects[$application->packageID] ?? null;
}
/**
* Searches for cached core object definition.
*
* @param string $className
- * @return string
+ * @return string|null
*/
final protected static function getCoreObject($className)
{
- if (isset(self::$coreObjectCache[$className])) {
- return self::$coreObjectCache[$className];
- }
+ return self::$coreObjectCache[$className] ?? null;
}
/**
public static function getActivePage()
{
if (self::getActiveRequest() === null) {
- return;
+ return null;
}
if (self::getActiveRequest()->getClassName() === CmsPage::class) {
return PageCache::getInstance()->getPage($metaData['cms']['pageID']);
}
- return;
+ return null;
}
return PageCache::getInstance()->getPageByController(self::getActiveRequest()->getClassName());