if anonymous users don't have the proper rights for the input format used at node creation, they see "n/a" instead of the actual body

in classified.module, line 1425, i think the code
check_markup($node->body, $node->format)
should be
check_markup($node->body, $node->format, FALSE)

Comments

fgm’s picture

Makes sense. I'll check in more depth but you are probably right.

Can you provide a patch including a simpletest catching the error in the current situation ?

murfi’s picture

StatusFileSize
new537 bytes

i'm not sure what you are asking me; i hope this helps

how to repeat
1. set 'full html' input format for admin user and 'filtered html' as default input format
2. create an ad as admin
3. anonymous user sees 'n/a' as the body of the ad

i attached a patch with the change i proposed; i didn't have the time to check if there are some unexpected side effects

fgm’s picture

Status: Active » Needs work

Good start.

Now the next step is to convert the number steps you described to a test function to add to tests/classified_basic.test so that it catches this error before the fix, and no longer gets it when the fix is applied.

jasonmce’s picture

Title: body displays n/a for anonymous users » patch worked for me - body displays n/a for anonymous users

Just giving you 3rd party confirmation in case you were curious.

underq’s picture

Status: Needs work » Needs review
StatusFileSize
new6.26 KB

I have create a patch and simpletest which fails before the patch and passes with the patch applied

fgm’s picture

Status: Needs review » Needs work
+++ b/tests/classified_basic.test
@@ -150,14 +151,34 @@ class ClassifiedBasicTest extends DrupalWebTestCase {
+    // Change the filter type & save cause settings do not change format
+    $node->format = 2;
+    node_save($node);

This is not needed: format can be saved upon node creation. Place it in $settings before nodeCreate().

+++ b/tests/classified_basic.test
@@ -150,14 +151,34 @@ class ClassifiedBasicTest extends DrupalWebTestCase {
+    $this->assertNoText(t('n/a'), $this->group);

Incorrect API use for assertNoText(): missing message.

fgm’s picture

Rerolled to take into account previous comments.

Also explicitly set node creator to "creator user", in order to avoid all-powerful user 1 bypassing checks and added a logout step

fgm’s picture

Title: patch worked for me - body displays n/a for anonymous users » body displays n/a for anonymous users
Status: Needs work » Fixed

Committed to 6.x-3.x, thanks murfi, underq.

@JasonMcE: please do not modify issue titles that way: only change an issue title to make it accurate for the whole thread, not just the latest comment.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.