This issue appears when creating new content only, once content has been created the module works fine if you edit a node.

Notice: Undefined variable: settings in node_level_blocks_fieldset_node_edit_form() (line 126 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).
Notice: Trying to get property of non-object in node_level_blocks_fieldset_node_edit_form() (line 126 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).
Notice: Undefined variable: settings in node_level_blocks_fieldset_node_edit_form() (line 134 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).
Notice: Trying to get property of non-object in node_level_blocks_fieldset_node_edit_form() (line 134 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).
Warning: in_array() expects parameter 2 to be array, null given in node_level_blocks_fieldset_node_edit_form() (line 134 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).
Notice: Undefined variable: settings in node_level_blocks_fieldset_node_edit_form() (line 126 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).
Notice: Trying to get property of non-object in node_level_blocks_fieldset_node_edit_form() (line 126 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).
Notice: Undefined variable: settings in node_level_blocks_fieldset_node_edit_form() (line 134 of C:\workspace\server\drupal714\sites\all\modules\node_level_blocks\node_level_blocks.admin.inc).

Comments

Dexter0015’s picture

Same for me.

Dexter0015’s picture

Status: Active » Needs review

I think I manage to fix this issue.

Sorry for not displaying a patch but I'm not used to work with GIT for the moment so I will only explain the changes I've made.

In node_level_blocks.admin.inc around line 100, replace this :

// If a node is submitted with the 'preview' button,
// the data can be collected using the form state.
// Othewise the stored nodes, or default values can be used.
if ($form_state['submitted']) {
    $node_blocks = array();
    $settings = $form_state['values']['node_level_blocks']['blocks']['settings'];
    unset($form_state['values']['node_level_blocks']['blocks']['settings']);
    foreach ($form_state['values']['node_level_blocks']['blocks'] as $node_block) {
      $node_blocks[$node_block['bid']] = (object) $node_block;
    }
}
else {
    if(isset($form['#node']->node_level_blocks['settings'])) {
		$settings = $form['#node']->node_level_blocks['settings'];
		$node_blocks = $form['#node']->node_level_blocks['blocks'];
    }
}

By this :

// If a node is submitted with the 'preview' button,
// the data can be collected using the form state.
// Othewise the stored nodes, or default values can be used.
if ($form_state['submitted']) {
   $node_blocks = array();
	if(isset($form_state['values']['node_level_blocks']['blocks']['settings'])) {
		$settings = $form_state['values']['node_level_blocks']['blocks']['settings'];
		unset($form_state['values']['node_level_blocks']['blocks']['settings']);
	}
	else {
		$settings = node_level_blocks_node_type_settings($form['#node']->type);
	}
	
	foreach ($form_state['values']['node_level_blocks']['blocks'] as $node_block) {
	  $node_blocks[$node_block['bid']] = (object) $node_block;
	}
}
else {
	  if(isset($form['#node']->node_level_blocks['settings'])) {
		$settings = $form['#node']->node_level_blocks['settings'];
		$node_blocks = $form['#node']->node_level_blocks['blocks'];
	  }
	  else {
		  $settings = node_level_blocks_node_type_settings($form['#node']->type);
	  }
}

Seems to works for me. If anyone can confirm...

ericclaeren’s picture

Priority: Normal » Major
StatusFileSize
new1.24 KB

Hi Dexter0015, thanks for your help, ran into the same problem.

I have rewritten your code to eliminate some else statements and I have attached a patch for this issue, maybe the maintainers could review it?

  // set default settings
  $settings = isset($form['#node']->node_level_blocks['settings']) ? $form['#node']->node_level_blocks['settings'] : node_level_blocks_node_type_settings($form['#node']->type);
  $node_blocks = isset($form['#node']->node_level_blocks['blocks']) ? $form['#node']->node_level_blocks['blocks'] : array();
  
  // If a node is submitted with the 'preview' button,
  // the data can be collected using the form state.
  // Othewise the stored nodes, or default values can be used.
  if ($form_state['submitted']) {
    $node_blocks = array();
    $settings = $form_state['values']['node_level_blocks']['blocks']['settings'];
    unset($form_state['values']['node_level_blocks']['blocks']['settings']);
    foreach ($form_state['values']['node_level_blocks']['blocks'] as $node_block) {
      $node_blocks[$node_block['bid']] = (object) $node_block;
    }
  }
Dexter0015’s picture

StatusFileSize
new1.87 KB

Thanks.

Unfortunatly I wasn't able to apply your patch, git returns me the following error:

error: while searching for:
    // set default theme for retrieving regions and blocks
    $theme_key = variable_get('theme_default', 'garland');

    // If a node is submitted with the 'preview' button,
    // the data can be collected using the form state.
    // Othewise the stored nodes, or default values can be used.

error: pathc_failed: node_level_block.admin.inc:89
error: node_level_blocks.admin.inc patch does not apply

I guess where is a difference between our line numbering, don't know why.

So I apply your change myself and make a new patch (just in case).
I finally tried git ;)

ericclaeren’s picture

Weird, I made the patch with the git repo, as the Drupal guide for creating patching describes.

Have you also tried?
patch -p1 < node_level_blocks-1747994-2.patch

Thanks.

Dexter0015’s picture

You're right !

with :
patch -p1 < [patchname.patch]

your patch is correctly applied.

I was using :
git apply -v [patchname.patch]

as described in the drupal guide, and get the error previously mentionned.

Sorry, but I didn't know "patch -p" command (as I'm just starting using git...).

Could you tell me what is the difference between this 2 commands?

ericclaeren’s picture

Hi, the difference (http://drupal.org/node/60108)

Note: git apply will fail to do anything when used within a local checkout of a git repository (other than the one for the project the patch is made for), such as if you are patching a module that is within a site that is in Git version control. Use patch -p1 < path/file.patch instead. You can find more info about applying patches with Git in the Git handbook

Dexter0015’s picture

Thanks !

Johnny vd Laar’s picture

Status: Needs review » Closed (fixed)

These changes are committed

Dexter0015’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta1
Status: Closed (fixed) » Active

Thanks !

Unfortunately, I still have some error messages when I save a node without blocks affected.

In edit form only, creation form seems to be ok for me.

Johnny vd Laar’s picture

Can you provide me the error messages?

Dexter0015’s picture

Sorry,

This one appears on the top of the list :

Notice : Undefined index: settings dans node_level_blocks_block_list_alter() (ligne 140 dans /.../modules/node_level_blocks/node_level_blocks.module).

Then, this one appears several times :

Notice : Trying to get property of non-object dans overlay_block_list_alter() (ligne 440 dans /.../modules/overlay/overlay.module).

It seems to be related to the overlay (I guess) because if I edit a node without using overlay, I don't get any error...

Johnny vd Laar’s picture

okay that makes sense as I never use overlay ;-)

I will investigate.

Johnny vd Laar’s picture

Status: Active » Fixed

I have committed a fix for this problem. Please review and reopen if needed.

Dexter0015’s picture

I've updated my files from your last commit, but still have the same error messages.

Plus Drupal.org added this to the .info where Module's version is wrong :

; Information added by drupal.org packaging script on 2011-08-11
version = "6.x-1.4"
core = 7.x
Johnny vd Laar’s picture

Assigned: Unassigned » Johnny vd Laar
Status: Fixed » Needs work

Hmm worked for me. I'll investigate again.

The info file still contained old code. I'll fix that too.

Johnny vd Laar’s picture

Committed a fix for the info file but I can't seem to find any bugs in the node save now, using overlay. Can you verify if the bug still exists with the latest dev version?

Dexter0015’s picture

Priority: Major » Minor
Status: Needs work » Closed (cannot reproduce)

Ok, I've updated from the last dev version and installed it on a new drupal installation (7.19).
And...

I can't reproduce the bug. (so i apologize)

Maybe it's a conflict with on of the other modules I have on the website where I have the bug.

Anyway, thank you so much for taking the time to look for, and sorry for wasting of your time...

And I really thinking about stopping using the overlay as it seems to be really heavy and slow sometimes.

Johnny vd Laar’s picture

I found another bug in nlb with overlay that I just patched that added blocks to region -1.

Dexter0015’s picture

Status: Closed (cannot reproduce) » Closed (fixed)

I think you found the solution because I've just test your last commit and I don't have anymore error.

Thank you!

  • Commit 4bb0d97 on 7.x-1.x, 7.x-2.x:
    Issue #1833472 by dreamlabs: D7 Port and node form submit issue on file...
  • Commit 3ffecb2 on 7.x-1.x, 7.x-2.x by Johnny vd Laar:
    Issue #1679174 by chrisns,rudiedirkx: Added a node_level_blocks_alter...
  • Commit 62200b7 on 7.x-1.x, 7.x-2.x by Johnny vd Laar:
    Issue #1747994 by Dexter0015: Bugfix in info file.