PHP E' Notice Fix: for Uninitialized string offset: 0 in semantic_cck_preprocess_content_field()

Edit + Change: [semantic_cck.module]

function semantic_cck_preprocess_content_field(&$variables) {
  $element = $variables['element'];
  $field = content_fields($element['#field_name'], $element['#node']->type);
  $num_items = count($variables['items']);

- if (!isset($field['semantic_cck_field_settings']) || !$field['semantic_cck_field_settings']['enabled']) {
+ if (empty($field['semantic_cck_field_settings']) || empty($field['semantic_cck_field_settings']['enabled'])) {
    return;
  ..
  ..
CommentFileSizeAuthor
#1 prevent-notice-1315704-1.patch986 byteseelkeblok

Comments

eelkeblok’s picture

StatusFileSize
new986 bytes

We also ran into this issue, but I think the above patch breaks the intended behaviour of this code, because when $field['semantic_cck_field_settings']['enabled'] == false, empty($field['semantic_cck_field_settings']['enabled']) will in fact be false, while the if-clause should be true in that case also (it will work in most cases, because if the semantic_cck settings *have* been set, they are usually enabled too).

Attached is a patch that, I believe, does have the intended behaviour.

avpaderno’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)
Issue tags: -Uninitialized string offset: 0 in semantic_cck_preprocess_content_field()

I am closing this issue, since it's for a Drupal version no longer supported.