1. Create a new node.
  2. Insert some random content in the body.
  3. Save the node.
  4. Edit the node.
  5. Delete all content and replace it with something completely different.
  6. Preview the node.

The body text box will contain the old teaser as well as your new content.

Comments

pwolanin’s picture

I can confirm this (PHP 4.4.7) - it also happens when JS is disabled.

pwolanin’s picture

Is it possible that this issue is a manifestation of this bug? http://drupal.org/node/146667

yasheshb’s picture

StatusFileSize
new162.08 KB

i tested this on php 5.2.3 and did the following steps to reproduce and check the problem.

1 - created a page "Page 2"
2 - save node
3 - edit node - removed "Page 2" from body and added "New Page 2".
4 - clicked on Preview button.
on clicking the preview button, i got a whole bunch of php notices

----------------------------------------------------------------------------------------------------------------------------------------------------------------
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 48.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 49.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 74.
* notice: Undefined index: in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 1161.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 75.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 75.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 78.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 51.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/forum/forum.module on line 434.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 48.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 49.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 74.
* notice: Undefined index: in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 1161.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 75.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 75.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 78.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 51.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/forum/forum.module on line 434.
* notice: Trying to get property of non-object in /work/projects/testsites/drupal/6.x/testsite8/www/modules/taxonomy/taxonomy.module on line 742.
----------------------------------------------------------------------------------------------------------------------------------------------------------------

also the preview shows the preview pane with
"Page 2"
"New Page 2"

and also in the body of the form it shows
"Page 2"
"New Page 2"

Note: i've created a taxonomy vocabulary "Tips & Tricks" and nodes of type Page and Story can be categorized using that vocabulary.

prakashp’s picture

Status: Active » Needs review
StatusFileSize
new745 bytes

The attached patch fixes the problem. Kindly review.

thanks

prakash patel

pwolanin’s picture

Status: Needs review » Needs work

This situation happens, apparently, for other submit buttons on the node form as well, not just Preview. So, this patch does not fix the problem in a general enough way. It seems the code is fundamentally flwed since it does not consider the node form as a multistep form.

pwolanin’s picture

Status: Needs work » Needs review
StatusFileSize
new1.67 KB

A more general approach. Seems to work.

pwolanin’s picture

StatusFileSize
new2.95 KB

An alternate approach suggested by chx. An even more general fix.

eaton’s picture

Status: Needs review » Reviewed & tested by the community

It works, it's clean, and the sensibly-named helper function is an improvement. Two thumbs up!

chx’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.21 KB

Yes, but we can do even better. I renamed the function to make it more evident that it's a submit function, added rebuild TRUE inside the function which made book_pick_book_submit unneeded. The less, the merrier!

chx’s picture

StatusFileSize
new5.41 KB

So, I am looking at node_form_submit and 'wow there is more code to be removed!' so there. And even more could be removed but then the extractor would not be able to find the strings to be localized, so I have only lightly touched watchdog and drupal_set_message .

gábor hojtsy’s picture

Status: Needs review » Needs work

- The docs on the book #submit handler are indented one more whitespace then they should be.
- I don't understand what's a "fixed-up node" as referred to in the phpdoc.
- "In the unlikely case something went wrong you will get the same" Reading this sentence, my question is: The same what?

chx’s picture

Status: Needs work » Needs review
StatusFileSize
new3.56 KB

I always love when the commiters are picking on comments. As for what's a fixed-up node, well, it's a node that's fixed up. I can't really explain it, I will ask others.

chx’s picture

StatusFileSize
new5.47 KB

Poor book module, it was left out from the aptch.

gábor hojtsy’s picture

OK, this question might help: what is the different between a not-fixed-up node and a fixed-up node?

pwolanin’s picture

StatusFileSize
new6.44 KB

ok, perhaps this comment is better - "fixed-up" just means the form values are processed via the submit handles.

Also, this patch uses the same submit function in upload module - right now uploads fail if JS is disabled. This is a better version of the fix proposed here: http://drupal.org/node/150463

chx’s picture

Yes, yes, YES! Upload module *fixed*!!

pwolanin’s picture

StatusFileSize
new6.41 KB

oops - one flaw. The message "The node could not be saved." was always being displayed.

eaton’s picture

Status: Needs review » Active

Tested and checked. A pretty clean fix that doesn't do anything nasty. There is one remaining gotcha. If:

1) JS is turned off
2) A file is selected for uploading
3) The attach button is NOT clicked
4) The SUBMIT button NOT the Preview button, is clicked...

The file never gets saved.

I'm of the mind that the non-JS-didn't-click-attach-and-didn't-preview issue is something that should be dealt with separately. This fixes the serious teaser-related preview issues and several others.

eaton’s picture

Status: Active » Reviewed & tested by the community

Whoops. Given my comments, 'active' was obviously a typo. Or perhaps a 'selecto.' I meant to set this RTBC.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the better documentation! Highly appreciated! Committed!

Anonymous’s picture

Status: Fixed » Closed (fixed)