Most probably related to #1907278: missing title when used with title and entity translation modules, but with details to reproduce the issue.

So, I have tried 7.x-1.0 up to 7.x-1.2 as well as 7.x-dev and could reproduce it constantly.

Using entity_translation and title_field modules, I have a content type (News). I create a new one and set a publish date. The language I choose is different, e.g. German. Now, when publishing the node using the English URL for cron (run manually, with or without a cron-key, or using scheduler's lightweight cron) it publishes the node but the title gets removed.

I also got it to work by creating the content in English and choosing the German cron URL (i.e. http://dev.mysite.com/de/admin/reports/status/run-cron) with the same result. When running cron in the same language this problem didn't occur.

The default language for the site is English.

After debugging I found that the _scheduler_publish function loads the node but the title is NULL. I don't know if the cache is language based, but when using node_load($nid, NULL, TRUE) it worked and the title appeared correctly. I have a patch attached. I also applied this fix to the _scheduler_unpublish function too, though I haven't tested if the problem also occurs there.

CommentFileSizeAuthor
#17 title_missing_on_publish-2339221-17.patch999 bytesJ-Lee
#5 scheduler-fix_title_field_empty-2339221-5.patch776 bytesAnonymous (not verified)
#4 scheduler_fix-title-field-empty_2339221_2.patch776 bytesAnonymous (not verified)
#1 scheduler_fix-title-field-empty_2339221_1.patch828 bytesAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Added patch

Anonymous’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: scheduler_fix-title-field-empty_2339221_1.patch, failed testing.

Anonymous’s picture

Corrected path for file

Anonymous’s picture

Wrong comment number in patch and swapped hypens/underscores based on the patchname suggestion.

Anonymous’s picture

Status: Needs work » Needs review
Anonymous’s picture

Issue summary: View changes
pfrenssen’s picture

This is probably not Scheduler's fault but rather the module that first populates the node_load() cache incorrectly.

Can you replicate this problem using only the Scheduler module on a clean installation? Can you perhaps debug the page request and see who does the very first call to node_load() with that node id? That will give some vital clues to the actual cause of the problem.

Anonymous’s picture

Hello, I can't really test it, as it takes too much time to setup a clean environment. I'm using a the title module too though, in case you missed that.

On saving the node, menu.inc from drupal_bootstrap calls it. Is it cached from then on? When running cron, the first node_load does occur from the scheduler. I found out though, calling node_load($nid, NULL, TRUE) once is not enough??? Now when calling it twice after eachother it works.

No idea what is going on here.

pfrenssen’s picture

Category: Bug report » Support request
Priority: Major » Normal

This problem is likely specific to your installation. Scheduler is just using node_load() and expects it to contain correct data. For some reason it is cached incorrectly. This may be due to a number of reasons, maybe a module is altering the node when it is loaded? It could be the Title module, or perhaps some other module.

It's very hard to assist you with this, as every Drupal site has a unique configuration and combination of modules. If this was reproducible on a clean install it would be a lot easier to figure out.

If you really want to get to the bottom of the problem then the best thing is to use a debugger and "watch" the node as it is populated. This can be time consuming but as you step through the code you will see exactly what's going on and what causes the problem. You can also try disabling some modules to see if the problem disappears. That will help to narrow down the problem.

If you don't have the energy or time to dive deeply in this I can fully understand :)

Anonymous’s picture

I will see if I get to it within the next few days.

Some more details: The node array (after scheduler loads it) has a "title" (not title-field) with the value NULL and another array element called "title_original" exists (though searching the code doesn't show any usage of it). When resetting the node's cache (twice), the title field contains the correct title and the "title_original" element is gone. The title FIELD array element is always correct.

Edit:

I see now where the problem might be occurring, either it's a title or an entity_translation error. Are you able to move this issue to the Title module or should I open a new one?

Title function title_field_sync_get calls is:

function title_field_sync_get($entity_type, $entity, $legacy_field, $info, $langcode = NULL) {
  if (property_exists($entity, $legacy_field)) {
    // Save the legacy field value to LEGACY_FIELD_NAME_original.
    $entity->{$legacy_field . '_original'} = $entity->{$legacy_field};
    // Find out the actual language to use (field might be untranslatable).
    $langcode = field_language($entity_type, $entity, $info['field']['field_name'], $langcode);
    $values = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
    foreach ($values as $name => $value) {
      $entity->{$name} = $value;
    }
  }
}

The line $langcode = field_language($entity_type, $entity, $info['field']['field_name'], $langcode); returns LANGUAGE_NONE, and $values = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode); returns an empty title.

I guess for entity_translation, the $entity->language should be used instead of field_language?

If I add a watch with $langcode as 'de' it gets the correct title. Hard coding the $langcode and leaving the scheduler module as it was (without patch) worked as it should.

pfrenssen’s picture

Project: Scheduler » Title

Thanks for looking into this. I'll move this to the issue queue of the Title project, maybe the maintainers and users can provide some more insight.

jonathan1055’s picture

Changed plain issue url to dynamic link in summary, added related issue, so that the other one knows about this issue, and hid the old patches.

Anonymous’s picture

Could a maintainer please look at my comment (especially #11), maybe the problem's clear to you?

Anonymous’s picture

Status: Needs review » Needs work
bnorbi’s picture

#11 helped me

J-Lee’s picture

Status: Needs work » Needs review
FileSize
999 bytes

I have wrote a patch regarding to #11.
But definitely need review.

J-Lee’s picture

Status: Needs review » Needs work

I think, this is fixed with alpha8.
The patch (from #17) and #11 produce a wrong behavior (with alpha8).

Could someone confirm this ?

J-Lee’s picture

Status: Needs work » Closed (outdated)

I'm closing this, because it works since alpha 8.