The subjectproperty of the comment object is not set when previewing it on:

- comment module
- chameleon theme
- pushbutton theme

The error message is: notice: Undefined property: stdClass::$status

Comments

theborg’s picture

Title: Comment templates are not checking subject. » Comment templates are not checking status.

The status property of the comment object is not set when previewing it on:

- comment module
- chameleon theme
- pushbutton theme

The error message is: notice: Undefined property: stdClass::$status

gábor hojtsy’s picture

Status: Needs review » Needs work

Why not set the status instead, where it should be? We strive to have easy to do templating.

dvessel’s picture

Status: Needs work » Needs review
StatusFileSize
new2.35 KB

$comment->status set from "comment_form_add_preview()". Removed the isset() check from templates from other themes since it's no longer needed.

theborg’s picture

StatusFileSize
new4.1 KB

-Added $status variable, string conversion of the $comment->status at the function: template_preprocess_comment.

This allows the template to theme 3 different status:

a) comment-published,
b) comment-unpublished
c) comment-preview

-Sets $comment->status for background theme compatibility.

-Modified core themes to include $status variable instead of $comment->status.

gábor hojtsy’s picture

Status: Needs review » Needs work

- What is a background theme compatibility?
- if() is used without a {} wrapper
- // comment is used without space after //, and // at end of line, instead of on its own line indented properly, and with a dot at the end

theborg’s picture

StatusFileSize
new4.12 KB

Code style corrected, thanks Gabor.

For background compatibility I mean that the comment->style is set to avoid errors on contributed themes that maybe are using it.

gábor hojtsy’s picture

theborg: we don't build such backward compatibility cruft into our code. Instead, we document what changes are required in themes. Also, $status would need documentation in the default comment template file, modules/comment/comment.tpl.php.

theborg’s picture

StatusFileSize
new4.28 KB

Removed isset() check.
Added documentation in the default comment template file.

theborg’s picture

Status: Needs work » Needs review
dvessel’s picture

Status: Needs review » Needs work

Why does $status have a space prepended. Your assuming it would always be positioned as a second or greater class but the naming gives no indication of it. Even if it's documented, it's just odd. Who knows, it may be used for other things.

The spacing should be created inside the .tpl since it may be used for something else..

For example, this look wrong.

if ($status == ' comment-preview') {
  print [YADDA];
}

Not sure what was wrong with my previous patch. It was a simple fix.

theborg’s picture

Status: Needs work » Needs review
StatusFileSize
new5.09 KB

Removed the space prepended, as dvessel noted the new status variable can be used for other purposes than the class attribute.

Added the space to core themes.

@dvessel: I've added the variable because I agree with Gábor that the less logic on the templates the better.

dvessel’s picture

Status: Needs review » Fixed

I'm not seeing this bug. Must have been fixed elsewhere.

gábor hojtsy’s picture

Version: 6.x-dev » 7.x-dev
Category: bug » feature
Status: Fixed » Needs review

Well, even if any issue brought up here is fixed, the patches also introduce a new comment-preview class on the comment, so this can be recategorized as a feature for D7, even if the bug at hand was fixed in D6 already.

theborg’s picture

Version: 7.x-dev » 6.x-dev
Category: feature » bug

The bug persits:
Create a css theme and you'll get: notice: Undefined property: stdClass::$status in

dvessel’s picture

Status: Needs review » Reviewed & tested by the community

Sorry about that. I wasn't testing properly.

The latest patch still works with 1 hunk offset. So marking as ready.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Great, committed, thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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