chx mentioned in drupal-devel:
If someone is bored and want to code something, there is core work to do before we can go RC: custom block and comment uses filter_form. Thus their save routines need to be changed to the form execute model otherwise they won't work in some cases.

Attached is my work in progress to convert comment forms to the formapi _execute model

Posting, replying and previewing works. The theming on preview still needs work.

Comments

asimmonds’s picture

I will place this on hold until my defines patch in http://drupal.org/node/34295 is committed (or rejected outright). IMO it's too confusing to work on comment without some defines() in there.

asimmonds’s picture

StatusFileSize
new16.2 KB

More work in progress on this, I'd say it's nearly done (That's if i'm on the right track)

asimmonds’s picture

Status: Needs work » Needs review

OK, I'm going to open this up for review...

asimmonds’s picture

StatusFileSize
new16.38 KB

Re-roll for current HEAD

webchick’s picture

Patch applies cleanly. I've tried creating/editing/deleting comments, replying to other comments, and futzing around in the admin options screens and haven't run across any problems.

+1, especially as chx tells me this is critical to getting the RC out.

webchick’s picture

Status: Needs review » Reviewed & tested by the community

Changing status.

chx’s picture

Priority: Normal » Critical

Bumping priority (I already mailed Dries, but still).

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

asimmonds’s picture

Status: Fixed » Reviewed & tested by the community
StatusFileSize
new593 bytes

I used #post_process in my patch, which is now #after_build.

1 line patch to update comment.module.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks.

asimmonds’s picture

Status: Fixed » Needs review
StatusFileSize
new5.48 KB

Third try...

I've made a number of screwups and incorrect assumptions with this issue, at the moment, comment is a little broken, patch attached to fix some bugs but I don't think I have all the bugs that are related to this conversion.

Patch attempts to fix:
http://drupal.org/node/38850
http://drupal.org/node/38852
http://drupal.org/node/38864

Wesley Tanaka’s picture

I dislike immensely the fact that editing a comment automatically updates its timestamp. In a flat display forum, this would cause the comments to be displayed out of order if one of them got edited (which would be extraordinarily confusing). I must say that I like the strategy (not necessarily the code) taken in http://drupal.org/node/38864 a lot better -- namely if a field doesn't need touching, don't try to touch it.

I see the advantages of modifying the update as follows:

  • Security: There's no code path available for a non-priveliged user to accidentally update a field in the database that they don't have permission to -- if the validate function doesn't allow a particular field through, there's no SQL code that even touches that field in the database.
  • Performance/Correctness: In the general case, a selective update in form processing would guarantee that a field wouldn't have to be selected out of the database first in order to preserve an existing value. It would also prevent any "professors and chalkboard"-type race conditions from coming up.
  • Code Simplicity: Rather than needing to set defaults for all the database fields that are specified as needing updating in the UPDATE query, from all code paths that might approach the query, a "keep this default" is as simple as not adding that field to an array. Code size shrinks.
  • Code Maintenance: With the fixed fields in the query, a database schema change absolutely must be reflected in three places -- the code that maintains the schema, the SQL query itself called by db_query, and code that sets defaults for the fields that are referred in the db_query call. With the approach taken in bug 38864, that list will be reduced to one in some cases: the database schema code. In all other cases, it will be reduced to two: the schema code and changes to the code that sets defaults.

For these reasons, I am reopening bug 38864, as I believe that patch should be applied in preference to the approach taken here.

Wesley Tanaka’s picture

The code maintenance effect can be seen in the current proposed patch in this bug.

According to http://drupal.org/node/38864#comment-56558:

Out of all the $edit indices referred to in the update statement, 'status', 'timestamp', 'format' and 'name' aren't set by default.

It seems that the current patch possibly hasn't addressed 'format' or 'name'. With the patch in http://drupal.org/node/38864
these would get handled automatically.

asimmonds’s picture

Assigned: asimmonds » Unassigned
Status: Needs review » Active

wtanaka:
You sound like you know what you want, and are more experienced with this than I am, so do you want to deal with these comment bugs? (Other project commitments are pending)

Stefan Nagtegaal’s picture

Some little nitpicking:

+  $output = "<a id=\"comment-form\"></a>\n";

Looks nicer if we do:

+  $output = '<a id="comment-form"></a>';
chx’s picture

Status: Active » Needs review
dries’s picture

Please adhere to the Drupal 4.6 behavior.

Wesley Tanaka’s picture

StatusFileSize
new3.78 KB

At Dries's request, I am going to:

> attempt to fix the other outstanding issues that
> I've found with the comment module and submit a patch
> corresponding to the comment.module that's running on my live site.

I'm attaching the patch that I'm currently running with at the moment, in case anyone's interested.

There's some site-specific hacks in the first hunk of the patch (some things not being themeable in hook_block), but if you take those out, the things which have been fixed are:
1) blank subjects get replaced with the first part of the body of the comment when the comment is posted
2) updates to the comment don't touch fields that aren't set in the form. (fixes http://drupal.org/node/38864)
3) #comment-form anchor added back into the page.

The things that I still plan to add to the patch are:

1) I don't know if this patch does "blank subject replacement" for the preview, since I didn't think about it when I created the patch. I'm going to confirm one way or other and fix if necessary.
2) http://drupal.org/node/38944 -- if it turns out to be a problem in comment.module

It would also be nice if these other comment related issues get fixed:

1) http://drupal.org/node/38845 (comments disabled by default -- includes patch)

chx’s picture

Status: Needs review » Needs work

please do not include site specific stuff.

Wesley Tanaka’s picture

StatusFileSize
new10.48 KB

Current state of my site. Still need to check on the preview thing.

Wesley Tanaka’s picture

Status: Needs work » Needs review
StatusFileSize
new10.98 KB

Preview gets subject properly added as well.

killes@www.drop.org’s picture

I don't think we want to put in another permission for the current release cycle. Can you please make a patch that only fixes the problem at hand?

chx’s picture

Status: Needs review » Needs work

Really sorry, I do not like the sqlparts thing. It's hard to read. I think a switch statement would be more apt. I do not think there is another thing like that in Drupal core.

Wesley Tanaka’s picture

As far as the extra permission, I'll advocate for something along those lines as being necessary for drupal's forums to be used on any forum where the site administrator is not acting as the forum moderator, or where there are several forum moderators.

As far as the switch statement, i don't see how a switch statement could get the same effect, without some kind of exponential combination explosion. As far as other examples in Drupal core, I seem to remember user_load() doing something similar.

Wesley Tanaka’s picture

A proposal:

1. immediately switch this task to "fixed," since the conversion mentioned in the title is actually complete (but has introduced some regression bugs)
2. split the patch (after upgrading it to apply cleanly against HEAD) into as many mini-patches as possible, such that each mini-patch is conceptually coherent.
3. post the url of each new mini-patch issue here for posterity

This allows the mini-patches that people like to get committed quickly, and the other mini-patches that people don't like to languish in the bug system unobtrusively.

Wesley Tanaka’s picture

Status: Needs work » Fixed

Implementing step 1 of comment #25

Wesley Tanaka’s picture

Wesley Tanaka’s picture

Wesley Tanaka’s picture

Wesley Tanaka’s picture

Wesley Tanaka’s picture

Wesley Tanaka’s picture

Wesley Tanaka’s picture

Wesley Tanaka’s picture

Wesley Tanaka’s picture

That's it. I also just confirmed that the split up patches, combined, get me all the fixes.

Anonymous’s picture

Status: Fixed » Closed (fixed)