Remove the Page::$isLandingPage property
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 1 Jun 2022 12:20:28 +0000 (14:20 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 1 Jun 2022 12:20:28 +0000 (14:20 +0200)
This property is redundant with wcf1_application.landingPageID for the 'wcf'
app. Previously it needed to be kept in sync across both tables which didn't
really work well in all cases. Remove this property to gain a single source of
truth for the landing page.

wcfsetup/install/files/acp/post_install.php
wcfsetup/install/files/acp/templates/pageAdd.tpl
wcfsetup/install/files/acp/templates/pageList.tpl
wcfsetup/install/files/lib/acp/form/ApplicationManagementForm.class.php
wcfsetup/install/files/lib/acp/form/PageAddForm.class.php
wcfsetup/install/files/lib/acp/form/PageEditForm.class.php
wcfsetup/install/files/lib/data/page/Page.class.php
wcfsetup/install/files/lib/system/cache/builder/PageCacheBuilder.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index 7896efb8fecfe85a931593b5094af89755c4a871..886f4ab405623098952b93efa580bb58ed90ee23 100644 (file)
@@ -8,13 +8,17 @@ use wcf\data\user\UserProfileAction;
 use wcf\system\WCF;
 
 // set default landing page
-$sql = "UPDATE  wcf" . WCF_N . "_page
-        SET     isLandingPage = ?
-        WHERE   identifier = ?";
-$statement = WCF::getDB()->prepareStatement($sql);
+$sql = "UPDATE  wcf1_application
+        SET     landingPageID = (
+                    SELECT  pageID
+                    FROM    wcf1_page
+                    WHERE   identifier = ?
+                )
+        WHERE   packageID = ?";
+$statement = WCF::getDB()->prepare($sql);
 $statement->execute([
-    1,
     'com.woltlab.wcf.Dashboard',
+    1,
 ]);
 
 // update administrator user rank and user online marking
index 16c87aed37deaf8b8979a21eb2eead38a334485a..9fefd9594c7a484231aa79518d3d043a6d1a602d 100644 (file)
@@ -1,34 +1,5 @@
 {include file='header' pageTitle='wcf.acp.page.'|concat:$action}
 
-<script data-relocate="true">
-       $(function() {
-               var isDisabled = elById('isDisabled');
-               if (isDisabled !== null) {
-                       $('#isLandingPage').change(function() {
-                               if ($('#isLandingPage')[0].checked) {
-                                       isDisabled.checked = false;
-                                       isDisabled.disabled = true;
-                               }
-                               else {
-                                       isDisabled.disabled = false;
-                               }
-                       }).trigger('change');
-               }
-
-               {if $action != 'edit' || !$page->isLandingPage}
-                       $('#isDisabled').change(function(event) {
-                               if ($('#isDisabled')[0].checked) {
-                                       $('#isLandingPage')[0].checked = false;
-                                       $('#isLandingPage')[0].disabled = true;
-                               }
-                               else {
-                                       $('#isLandingPage')[0].disabled = false;
-                               }
-                       }).trigger('change');
-               {/if}
-       });
-</script>
-
 {if $action == 'add'}
        <script data-relocate="true">
                elById('name').addEventListener('blur', function() {
                                        </dd>
                                </dl>
 
-                               {if $action != 'edit' || (!$page->requireObjectID && !$page->excludeFromLandingPage)}
-                                       <dl>
-                                               <dt></dt>
-                                               <dd>
-                                                       <label><input type="checkbox" id="isLandingPage" name="isLandingPage" value="1"{if $isLandingPage} checked{/if}{if $action == 'edit' && $page->isLandingPage} disabled{/if}> {lang}wcf.acp.page.isLandingPage{/lang}</label>
-                                               </dd>
-                                       </dl>
-                               {/if}
-
                                {if $action != 'edit' || $page->pageType != 'system'}
                                        <dl>
                                                <dt></dt>
index 17c90b7ddece42a4956390f085e6bc62032d2437..ed3c6c6aec57c44bc1303932171cc5c5e6805387 100644 (file)
                                                        {event name='rowButtons'}
                                                </td>
                                                <td class="columnID columnPageID">{@$page->pageID}</td>
-                                               <td class="columnTitle columnName">{if $page->isLandingPage}<span class="icon icon16 fa-home jsTooltip" title="{lang}wcf.acp.page.isLandingPage{/lang}"></span> {/if}<a href="{link controller='PageEdit' id=$page->pageID}{/link}">{$page->name}</a></td>
+                                               <td class="columnTitle columnName"><a href="{link controller='PageEdit' id=$page->pageID}{/link}">{$page->name}</a></td>
                                                <td class="columnText columnURL">
                                                        {if $page->applicationPackageID === null}
                                                                <span class="icon icon16 fa-exclamation-triangle red"></span> <span>{lang}wcf.acp.page.application.error.missing{/lang}</span>
index 85412bad42a95e20f4dc024893168c968de6921f..621db88de1af7b283658ecfc7444b2c19f966a29 100644 (file)
@@ -177,19 +177,6 @@ final class ApplicationManagementForm extends AbstractForm
 
         $this->saved();
 
-        if (!empty($this->landingPageID[1])) {
-            (new Page($this->landingPageID[1]))->setAsLandingPage();
-        } else {
-            $sql = "UPDATE  wcf" . WCF_N . "_page
-                    SET     isLandingPage = ?
-                    WHERE   isLandingPage = ?";
-            $statement = WCF::getDB()->prepareStatement($sql);
-            $statement->execute([
-                0,
-                1,
-            ]);
-        }
-
         ApplicationHandler::rebuild();
 
         // Reset caches to reflect the new landing pages.
index b018cc5dc21be27d87250effe696182f5fcf662a..c57a03b88c96a22cb4234363c2c462c9822b7752 100644 (file)
@@ -83,12 +83,6 @@ class PageAddForm extends AbstractForm
      */
     public $isDisabled = 0;
 
-    /**
-     * true if page is landing page
-     * @var bool
-     */
-    public $isLandingPage = 0;
-
     /**
      * application id of the page
      * @var int
@@ -303,9 +297,6 @@ class PageAddForm extends AbstractForm
         if (isset($_POST['isDisabled'])) {
             $this->isDisabled = 1;
         }
-        if (isset($_POST['isLandingPage'])) {
-            $this->isLandingPage = 1;
-        }
         if (isset($_POST['availableDuringOfflineMode'])) {
             $this->availableDuringOfflineMode = 1;
         }
@@ -628,7 +619,6 @@ class PageAddForm extends AbstractForm
                 'name' => $this->name,
                 'cssClassName' => $this->cssClassName,
                 'isDisabled' => $this->isDisabled ? 1 : 0,
-                'isLandingPage' => 0,
                 'availableDuringOfflineMode' => $this->availableDuringOfflineMode,
                 'allowSpidersToIndex' => $this->allowSpidersToIndex,
                 'enableShareButtons' => $this->enableShareButtons,
@@ -652,10 +642,6 @@ class PageAddForm extends AbstractForm
             'identifier' => 'com.woltlab.wcf.generic' . $page->pageID,
         ]);
 
-        if ($this->isLandingPage) {
-            $page->setAsLandingPage();
-        }
-
         // save acl
         SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.page', $page->pageID, $this->aclValues);
 
@@ -717,7 +703,7 @@ class PageAddForm extends AbstractForm
         ]);
 
         // reset variables
-        $this->parentPageID = $this->isDisabled = $this->isLandingPage = $this->availableDuringOfflineMode = $this->enableShareButtons = $this->addPageToMainMenu = 0;
+        $this->parentPageID = $this->isDisabled = $this->availableDuringOfflineMode = $this->enableShareButtons = $this->addPageToMainMenu = 0;
         $this->parentMenuItemID = null;
         $this->applicationPackageID = 1;
         $this->cssClassName = $this->name = '';
@@ -745,7 +731,6 @@ class PageAddForm extends AbstractForm
                 if ($this->presetPage->controllerCustomURL) {
                     $this->customURL[0] = $this->presetPage->controllerCustomURL;
                 }
-                $this->isLandingPage = 0;
                 $this->isDisabled = 1;
                 if ($this->presetPage->availableDuringOfflineMode) {
                     $this->availableDuringOfflineMode = 1;
@@ -821,7 +806,6 @@ class PageAddForm extends AbstractForm
             'name' => $this->name,
             'cssClassName' => $this->cssClassName,
             'isDisabled' => $this->isDisabled,
-            'isLandingPage' => $this->isLandingPage,
             'availableDuringOfflineMode' => $this->availableDuringOfflineMode,
             'allowSpidersToIndex' => $this->allowSpidersToIndex,
             'isMultilingual' => $this->isMultilingual,
index adb88b1a50b571bd9fad444a06186201f7ebbc3b..e5c730dfaec18889290a9ecc9c1609f3b846e71e 100644 (file)
@@ -97,11 +97,6 @@ class PageEditForm extends PageAddForm
         } else {
             $this->overrideApplicationPackageID = null;
         }
-
-        if ($this->page->requireObjectID || $this->page->excludeFromLandingPage) {
-            // pages that require an object id can never be set as landing page
-            $this->isLandingPage = 0;
-        }
     }
 
     /**
@@ -257,10 +252,6 @@ class PageEditForm extends PageAddForm
             $this->objectAction->executeAction();
         }
 
-        if ($this->isLandingPage != $this->page->isLandingPage) {
-            $this->page->setAsLandingPage();
-        }
-
         // save acl
         if ($this->page->pageType != 'system') {
             SimpleAclHandler::getInstance()->setValues('com.woltlab.wcf.page', $this->page->pageID, $this->aclValues);
@@ -290,9 +281,6 @@ class PageEditForm extends PageAddForm
             if ($this->page->controllerCustomURL) {
                 $this->customURL[0] = $this->page->controllerCustomURL;
             }
-            if ($this->page->isLandingPage) {
-                $this->isLandingPage = 1;
-            }
             if ($this->page->isDisabled) {
                 $this->isDisabled = 1;
             }
index 95996eb862c1e02cc183088430440bdfc8299141..d7e044eb50e985b47cef1aee4e1509d7f3efdaff 100644 (file)
@@ -34,7 +34,6 @@ use wcf\system\WCF;
  * @property-read   string $name                   monolingual name of the page shown in the ACP
  * @property-read   string $pageType               type of the page, default types: `text`, `html`, `tpl` `system`
  * @property-read   int $isDisabled             is `1` if the page is disabled and thus cannot be accessed, otherwise `0`
- * @property-read   int $isLandingPage              is `1` if the page is the landing page, otherwise `0`
  * @property-read   int $isMultilingual             is `1` if the page is available in different languages, otherwise `0`
  * @property-read   int $originIsSystem             is `1` if the page has been delivered by a package, otherwise `0` (i.e. the page has been created in the ACP)
  * @property-read   int $packageID              id of the package the which delivers the page or `1` if it has been created in the ACP
@@ -96,7 +95,7 @@ class Page extends DatabaseObject implements ILinkableObject, ITitledObject
      */
     public function canDelete()
     {
-        if (WCF::getSession()->getPermission('admin.content.cms.canManagePage') && !$this->originIsSystem && !$this->isLandingPage) {
+        if (WCF::getSession()->getPermission('admin.content.cms.canManagePage') && !$this->originIsSystem) {
             return true;
         }
 
@@ -110,7 +109,7 @@ class Page extends DatabaseObject implements ILinkableObject, ITitledObject
      */
     public function canDisable()
     {
-        if (WCF::getSession()->getPermission('admin.content.cms.canManagePage') && (!$this->originIsSystem || $this->pageType != 'system') && !$this->isLandingPage) {
+        if (WCF::getSession()->getPermission('admin.content.cms.canManagePage') && (!$this->originIsSystem || $this->pageType != 'system')) {
             return true;
         }
 
@@ -277,9 +276,7 @@ class Page extends DatabaseObject implements ILinkableObject, ITitledObject
     }
 
     /**
-     * Sets the current page as landing page.
-     *
-     * @throws  SystemException
+     * @deprecated 5.6 The landing page is a property of the 'wcf' app.
      */
     public function setAsLandingPage()
     {
@@ -288,24 +285,6 @@ class Page extends DatabaseObject implements ILinkableObject, ITitledObject
         }
 
         WCF::getDB()->beginTransaction();
-        // unmark existing landing page
-        $sql = "UPDATE  wcf" . WCF_N . "_page
-                SET     isLandingPage = ?";
-        $statement = WCF::getDB()->prepareStatement($sql);
-        $statement->execute([
-            0,
-        ]);
-
-        // set current page as landing page
-        $sql = "UPDATE  wcf" . WCF_N . "_page
-                SET     isLandingPage = ?
-                WHERE   pageID = ?";
-        $statement = WCF::getDB()->prepareStatement($sql);
-        $statement->execute([
-            1,
-            $this->pageID,
-        ]);
-
         $sql = "UPDATE  wcf" . WCF_N . "_application
                 SET     landingPageID = ?
                 WHERE   packageID = ?";
index d843e355015e5112a310764f067ceb44e8e9cf96..8f63bda979d98d3b821202af2b535adc1256c73b 100644 (file)
@@ -55,13 +55,20 @@ class PageCacheBuilder extends AbstractCacheBuilder
             $data['pageMetaDescriptions'][$pageID][$row['languageID'] ?: 0] = $row['metaDescription'];
         }
 
+        $sql = "SELECT  landingPageID
+                FROM    wcf1_application
+                WHERE   packageID = ?";
+        $statement = WCF::getDB()->prepare($sql);
+        $statement->execute([1]);
+        $landingPageID = $statement->fetchSingleColumn();
+
         // build lookup table
         /** @var Page $page */
         foreach ($pageList as $page) {
             $data['identifier'][$page->identifier] = $page->pageID;
             $data['controller'][$page->controller] = $page->pageID;
 
-            if ($page->isLandingPage || ($data['landingPage'] === null && $page->identifier === 'com.woltlab.wcf.ArticleList')) {
+            if ($page->pageID == $landingPageID || ($data['landingPage'] === null && $page->identifier === 'com.woltlab.wcf.ArticleList')) {
                 $data['landingPage'] = $page;
             }
         }
index 205c70a95662e0563771aa4adc1c715e4a4e79fb..4f128e7aee5e3060fd955e3b55e3872221307051 100644 (file)
@@ -2028,7 +2028,6 @@ Die Datenbestände werden sorgfältig gepflegt, aber es ist nicht ausgeschlossen
                <item name="wcf.acp.page.i18n.i18n.description"><![CDATA[Inhalt, URL und Meta-Daten werden individuell pro Sprache festgelegt.]]></item>
                <item name="wcf.acp.page.i18n.none"><![CDATA[Einsprachige Seite]]></item>
                <item name="wcf.acp.page.i18n.none.description"><![CDATA[Der Inhalt der Seite ist sprachneutral oder soll nur in einer Sprache verfasst werden.]]></item>
-               <item name="wcf.acp.page.isLandingPage"><![CDATA[Seite ist Startseite]]></item>
                <item name="wcf.acp.page.isDisabled"><![CDATA[Seite deaktivieren]]></item>
                <item name="wcf.acp.page.lastUpdateTime"><![CDATA[Letzte Aktualisierung]]></item>
                <item name="wcf.acp.page.list"><![CDATA[Seiten]]></item>
index e13d823ca328fb055e6c8d87853f20855fbaf3ea..b94d3ceaeb6d24eb5a76b95c3ff7cac2fe068fcc 100644 (file)
@@ -4401,7 +4401,6 @@ Attachments:
                <item name="wcf.acp.page.i18n.i18n.description"><![CDATA[The content, URL and meta data will be provided for each language separately.]]></item>
                <item name="wcf.acp.page.i18n.none"><![CDATA[Monolingual page]]></item>
                <item name="wcf.acp.page.i18n.none.description"><![CDATA[The content is not tied to a specific language or there should be no translation.]]></item>
-               <item name="wcf.acp.page.isLandingPage"><![CDATA[Landing page]]></item>
                <item name="wcf.acp.page.isDisabled"><![CDATA[Disable page]]></item>
                <item name="wcf.acp.page.lastUpdateTime"><![CDATA[Last Change]]></item>
                <item name="wcf.acp.page.list"><![CDATA[Pages]]></item>
index 2cd90f4c7a420d19749e4fbd392cde9b23730f8a..21632d71839f16ba000e7772aa90c1cc85c343ac 100644 (file)
@@ -1100,7 +1100,6 @@ CREATE TABLE wcf1_page (
        name VARCHAR(255) NOT NULL,
        pageType VARCHAR(255) NOT NULL,
        isDisabled TINYINT(1) NOT NULL DEFAULT 0,
-       isLandingPage TINYINT(1) NOT NULL DEFAULT 0,
        isMultilingual TINYINT(1) NOT NULL DEFAULT 0,
        originIsSystem TINYINT(1) NOT NULL DEFAULT 0,
        packageID INT(10) NOT NULL,