- Issue created by @mingsong
- ๐ฆ๐บAustralia mingsong ๐ฆ๐บ
The PHPUnit test to reproduce this issue.
The test should fail as expected.
- last update
over 1 year ago 29,473 pass, 2 fail - Status changed to Needs work
over 1 year ago 10:03pm 14 September 2023 - ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
-
+++ b/core/modules/forum/tests/src/Functional/ForumTermAccessTest.php @@ -0,0 +1,115 @@ + // Create a unpublished forum.
nit: a => an
-
+++ b/core/modules/forum/tests/src/Functional/ForumTermAccessTest.php @@ -0,0 +1,115 @@ + $unpublished_forum_name = $this->randomMachineName(8); + $edit = [ + 'name[0][value]' => $unpublished_forum_name, + 'description[0][value]' => $this->randomMachineName(200), + 'status[value]' => 0, + ]; + // Save a new unpublished forum. + $this->drupalGet('admin/structure/forum/add/forum'); + $this->submitForm($edit, 'Save'); + $assert_session->pageTextContains('Created new forum ' . $unpublished_forum_name); + + // Create a new published forum. + $published_forum_name = $this->randomMachineName(8); + $edit = [ + 'name[0][value]' => $published_forum_name, + 'description[0][value]' => $this->randomMachineName(200), + 'status[value]' => 1, + ]; + // Save the new published forum. + $this->drupalGet('admin/structure/forum/add/forum'); + $this->submitForm($edit, 'Save'); + $assert_session->pageTextContains('Created new forum ' . $published_forum_name);
Let's create these using the api, Term::create()->save()
We're not testing the add forum UI here, we're testing access so we don't need to use the form.
-
+++ b/core/modules/forum/tests/src/Functional/ForumTermAccessTest.php @@ -0,0 +1,115 @@ + $assert_session->statusCodeNotEquals(200);
let's be specific here and use statusCodeEquals(403)
We could have a 500 error here and the test would pass ๐
-
+++ b/core/modules/forum/tests/src/Functional/ForumTermAccessTest.php @@ -0,0 +1,115 @@ + private function reloadForumByName(string $name): TermInterface {
we won't need this if we use the API instead of the form to create the terms
Nice work on the tests, now we just need the fix ๐ช
-
- ๐ฆ๐บAustralia mingsong ๐ฆ๐บ
Thanks @Rowlands for review the test patch #2.
-
nit: a => an
Corrected.
-
Let's create these using the api, Term::create()->save()
Updated.
-
let's be specific here and use statusCodeEquals(403)
I thought the same. But when I checked the test from Taxonomy module, I saw this line https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/modules/tax...
Ideally, it should return 403 instead of 404. let's use 403 for now to see if the coming fix can pass the test. -
we won't need this if we use the API instead of the form to create the terms.
Removed.
Here is the updated patch.
Thanks again.
-
- last update
over 1 year ago 29,477 pass, 2 fail - ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
Test looks good, now we just need the fix, which will likely involve adding
_entity_access: 'taxonomy_term.view'
To the requirements section in the routing entry for forum.page and an access check to \Drupal\forum\Controller\ForumController::build that checks ->access('view') on each term, collects cacheability metadata from each return (return as object TRUE) and adds that to the render array.
- Assigned to mlncn
- ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
Will take a quick swing at this.
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 12:33am 28 October 2023 - ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
Sorry i looked at the cacheability metadata and turned my head inside out. Every example i looked at in core seemed not to line up in some way. The usual approach is to check access right in the query, the closest we have to that since frighteningly loadTree() does not have an access check parameter is to do it in ForumManager's getChildren with is used both for the index and forum pages, anywhere forums are listedโ but again no idea how to get that into cache metadata over in build the right way.
- last update
over 1 year ago 29,677 pass - last update
over 1 year ago 30,456 pass, 1 fail - last update
over 1 year ago Build Successful - last update
over 1 year ago 29,679 pass - Status changed to Needs work
over 1 year ago 4:50pm 8 November 2023 - ๐บ๐ธUnited States smustgrave
Appears to have failures in 11.x which it would need to be merged into first.
FYI patches are being phased out and it's encouraged to try gitlab. It's much faster and easier for reviews.
Thanks!
- Merge request !6607Issue #3387172 by mlncn,larowlan,Mingsong,smustgrave: Unpublished forum accessible to public โ (Open) created by mingsong
- Status changed to Needs review
about 1 year ago 4:06am 15 February 2024 - ๐ฎ๐ณIndia Kanchan Bhogade
Hi
Tested MR !6607 on Drupal version 11.x
Applied MR Successfully...Followed steps from the summary for reproducing the issue.
Test Result:
Removed the unpublished forums from the forum landing page for anonymous users as per the proposed solutionAttaching screenshots for references
RTBC++Keeping in "Need review" for more reviews
- Status changed to Postponed
about 1 year ago 4:12pm 15 February 2024 - ๐บ๐ธUnited States smustgrave
Forum is approved for removal. See #1898812: [policy] Deprecate forum module for removal in Drupal 11
This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
It will be moved to the contributed extension once the Drupal 11 branch is open.
- Status changed to Needs review
about 1 year ago 9:47pm 15 February 2024 Drupal core is moving towards using a โmainโ branch. As an interim step, a new 11.x branch has been opened โ , as Drupal.org infrastructure cannot currently fully support a branch named
main
. New developments and disruptive changes should now be targeted for the11.x
branch. For more information, see the Drupal core minor version schedule โ and the Allowed changes during the Drupal core release cycle โ .- ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
Thanks @smustgrave - because of the information disclosure here I think we should keep working on this just in case we miss removing forum again
- Status changed to RTBC
about 1 year ago 1:51am 17 February 2024 - ๐บ๐ธUnited States smustgrave
Hiding patches for clarity
Applied a simple suggestion to the test method
Ran test-only feature
There was 1 error: 1) Drupal\Tests\forum\Functional\ForumTermAccessTest::testForumTermAccess Behat\Mink\Exception\ResponseTextException: The text "z41709kq" appears in the text of this page, but it should not. /builds/issue/drupal-3387172/vendor/behat/mink/src/WebAssert.php:907 /builds/issue/drupal-3387172/vendor/behat/mink/src/WebAssert.php:312 /builds/issue/drupal-3387172/core/modules/forum/tests/src/Functional/ForumTermAccessTest.php:85 /builds/issue/drupal-3387172/vendor/phpunit/phpunit/src/Framework/TestResult.php:728 ERRORS!
Code change of checking forum access makese sense.
LGTM
- ๐ฌ๐งUnited Kingdom alexpott ๐ช๐บ๐
This bug was introduced by #2981887: Add a publishing status to taxonomy terms โ . the fix seems reasonable. I do wonder if status should be accounted for in \Drupal\taxonomy\TermStorage::loadTree() as that is adding the tag 'taxonomy_term_access' to it's query but afaik this is no different to nodes.
Committed and pushed f660bb4c1e to 11.x and 9397852246 to 10.2.x. Thanks!
-
alexpott โ
committed 93978522 on 10.2.x
Issue #3387172 by Mingsong, smustgrave, mlncn, Kanchan Bhogade, larowlan...
-
alexpott โ
committed 93978522 on 10.2.x
- Status changed to Fixed
about 1 year ago 9:48am 18 February 2024 -
alexpott โ
committed f660bb4c on 11.x
Issue #3387172 by Mingsong, smustgrave, mlncn, Kanchan Bhogade, larowlan...
-
alexpott โ
committed f660bb4c on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.