This is confirmation of the problem first noted by shunting here: http://drupal.org/node/201667#comment-668493.
Using ScribeFire, if I create a post, then if the teaser is the same as the body, when I view what should be the full post, it is blank. If the teaser is different from the body then the teaser is missing when I view the body. This is similar in many ways to the issue at http://drupal.org/node/201667. I think this is pretty critical, since it effectively stops BlogAPI from being used to create content?
I think the problem is in http://api.drupal.org/api/function/node_submit, here:
// Chop off the teaser from the body if needed.
if (empty($node->teaser_include) && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
My feeling is that this needs to be changed so that it also checks to see if $node->teaser_include is set (I imagine it will ?often not be set when a node is submitted/created programatically).
// Chop off the teaser from the body if needed.
if (isset($node->teaser_include) && !$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) {
This is consistent with the approach taken in http://drupal.org/node/201667. Will try this out and roll a patch when I have a mo, if someone else doesn't get there first.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | node_submit_216890.patch | 672 bytes | gpk |
Comments
Comment #1
gpk commentedAlso came across this problem when using BlogAPI: Multiple notices when creating a post via BlogAPI - http://drupal.org/node/216893
Comment #2
webernet commentedhttp://drupal.org/node/216608
Comment #3
pwolanin commentedis this really duplicate?
I'd tend to agree that the code highlighted is not very robust - it seems like the suggested code is better.
at the least it's a bug that blogapi is not setting $node->teaser_include
http://api.drupal.org/api/function/blogapi_blogger_new_post/6
it's especially a bug here, since $node->teaser is unset, but the boy will no longer have that part of the text:
http://api.drupal.org/api/function/blogapi_blogger_edit_post/6
Comment #4
gpk commentedI think I'd still argue that this should be fixed in node_submit() rather than in blogapi.module, since
- the convention when creating a node using the usual web-based node/edit form is that the teaser/summary should be included in page view by default. Seems sensible to use the same default for nodes created programatically via node_submit().
- I also think it makes more sense for the default to be that the teaser is included in page view. This is the way Drupal has done things in the past. Having a default "teaser not included", which can lead to Drupal auto-generating a teaser of unpredictable length and then chopping that out of the page view, is awkward to my mind. This forces any module/anyone who wants to create a node via node_submit() to set $node->teaser_include =1 (unless they want the "new", "exclude teaser" behaviour, in which case they are probably providing a separate teaser/summary-type field).
On the other hand could this be considered an API change -> not allowed? I'd be surprised if the current node_submit() "default" behaviour (which constitutes a change from D5) was ever intended in this situation, and I doubt many (if any) 6.x contrib modules rely on it. Any that already set $node->teaser_include to either 0 or 1 will be unaffected. But if we don't change it I can see dozens of forthcoming forum topics from confused aspiring developers (like me) asking why the teaser is missing from page view from the node they created programatically...
My vote is therefore to fix it in node_submit() ;-)
Patch attached. This makes posts submitted with ScribeFire behave nicely, and ScribeFire also retrieves the post just fine.
Comment #5
gpk commentedComment #6
keith.smith commentedWith the patch in #4 applied, and repeating my test from http://drupal.org/node/216608#comment-714865 :
Comment #7
gpk commentedThanks Keith, sounds good.
Just for the record, the fact that the entire text ends up in the top text area would be because the cursor starts off life at the bottom of the (single) Body textarea.
I should also say that I tested node creation using the web interface, and all cases seem to work OK (Summary "split" and "joined", and checkbox checked and unchecked) - i.e. web interface behaviour unchanged by this patch. Others should perhaps confirm.
Comment #8
catchDon't want to mark http://drupal.org/node/216608 as duplicate yet, but swapping the priority since this has a patch.
Comment #9
chx commentedNifty! As the node form has the
teaser_includecheckbox, this change does not affect it. The change only affects programatically submtted nodes through node_submit (if you drupal_execute then you are again using the form -- not affected) and what happens is much more natural. And yet if you want to use the new "Show summary in full view" mode, you still can by setting$node->teaser_include = 0just this is not the default. And this, indeed feels a much more natural default.Comment #10
pwolanin commentedthis looks good, but it still might be worth fixing blogapi as well.
Comment #11
gábor hojtsyLooks good, but I also added a bit of a comment, so it is evident and later a code cleanup will not remove it in the name of
isset() and !"equals"empty(). Committed, thanks.Comment #12
gpk commented@Gábor, chx: Nagyon kösi! Jó estét!
@pwolanin: I'm not sure there is a bug in blogapi.module ... the teaser gets unset, yes, but it will be regenerated later either automatically using the teaser length from Post settings, or using the <!--break--> tag if present in the body.
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.