From 4223f18186db2224ba069296c6de9039a10a6398 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 11 Feb 2018 21:46:28 +0100 Subject: [PATCH] Fixed handling of default values for page visibility for robots --- com.woltlab.wcf/package.xml | 2 ++ com.woltlab.wcf/update_3.1.0.sql | 6 ++++++ com.woltlab.wcf/update_3.1_3.sql | 8 ++++++-- .../plugin/PagePackageInstallationPlugin.class.php | 13 ++++++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 com.woltlab.wcf/update_3.1.0.sql diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index e2f1a576c7..a44643353f 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -95,6 +95,8 @@ defaultStyle.tar + + acptemplates_update.tar files_update.tar diff --git a/com.woltlab.wcf/update_3.1.0.sql b/com.woltlab.wcf/update_3.1.0.sql new file mode 100644 index 0000000000..45eb298586 --- /dev/null +++ b/com.woltlab.wcf/update_3.1.0.sql @@ -0,0 +1,6 @@ +-- Force-enable the visibility of *all* pages by setting `allowSpidersToIndex` to `2`. +-- +-- This value isn't valid by definition, but because it is considered to be a true-ish +-- value, we can use this to imply an "implicit yes" without breaking any checks. Check +-- the PagePackageInstallationPlugin to see what this magic value is good for. +UPDATE wcf1_page SET allowSpidersToIndex = 2; diff --git a/com.woltlab.wcf/update_3.1_3.sql b/com.woltlab.wcf/update_3.1_3.sql index 004a1dbd3b..129a0fc8a1 100644 --- a/com.woltlab.wcf/update_3.1_3.sql +++ b/com.woltlab.wcf/update_3.1_3.sql @@ -138,5 +138,9 @@ INSERT INTO wcf1_contact_option (optionID, optionTitle, optionDescription, optio -- default recipient: site administrator INSERT INTO wcf1_contact_recipient (recipientID, name, email, isAdministrator, originIsSystem) VALUES (1, 'wcf.contact.recipient.name1', '', 1, 1); --- force-enable the visibility of all non-system pages (the page.xml is shortly after and sets the exact values) -UPDATE wcf1_page SET allowSpidersToIndex = 1 WHERE pageType <> 'system'; +-- Force-enable the visibility of *all* pages by setting `allowSpidersToIndex` to `2`. +-- +-- This value isn't valid by definition, but because it is considered to be a true-ish +-- value, we can use this to imply an "implicit yes" without breaking any checks. Check +-- the PagePackageInstallationPlugin to see what this magic value is good for. +UPDATE wcf1_page SET allowSpidersToIndex = 2; diff --git a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php index cf6e518295..8ce0ccda42 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php @@ -270,12 +270,23 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin // allow update of `controller`, `handler` and `excludeFromLandingPage` // only, prevents user modifications form being overwritten if (!empty($data['controller'])) { + $allowSpidersToIndex = $row['allowSpidersToIndex']; + if ($allowSpidersToIndex == 2) { + // The value `2` resolves to be true-ish, eventually resulting in the same behavior + // when setting it to `1`. This value is special to the 3.0 -> 3.1 upgrade, because + // it force-enables the visibility, while also being some sort of indicator for non- + // user-modified values. The page edit form will set it to either `1` or `0`, there- + // fore `2` means that we can safely update the value w/o breaking the user's choice. + $allowSpidersToIndex = $data['allowSpidersToIndex']; + } + $page = parent::import($row, [ 'controller' => $data['controller'], 'handler' => $data['handler'], 'options' => $data['options'], 'permissions' => $data['permissions'], - 'excludeFromLandingPage' => $data['excludeFromLandingPage'] + 'excludeFromLandingPage' => $data['excludeFromLandingPage'], + 'allowSpidersToIndex' => $allowSpidersToIndex ]); } else { -- 2.20.1