Problem/Motivation

Recoverable fatal error: Argument 2 passed to delta_reduce() must be an array, null given, called in /sites/all/modules/delta/plugins/delta/delta_injection.inc on line 100 and defined i delta_reduce() (row 256 of /sites/all/modules/delta/delta.module).

I get this error on my new D7 install when adding a new delta.
Happens both on 7.x-3.0-beta10 and 7.x-3.x-dev, but 7.x-3.0-beta9 seems to work fine.

When the error happens, the settings I tried changing were ignored and did not get saved.
I tried changing the number of columns on the main content region and hiding one sidebar.

Steps to reproduce

1. Install delta-7.x-3.0-beta10.
2. Create a new delta based on omega theme.
3. Configure and change Region content: num columns to 9.
4. Save.

Expected result

The changes should get saved and no errors should appear.

Actual result

Above error is shown and changes are not saved.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lorenz’s picture

Priority: Normal » Major

*subscribe

Anonymous’s picture

Same issue the difference being I was trying to remove both sidebars from content region. Will downgrade to beta09 till this is resolved.

Thanks imevul for posting.

yannisc’s picture

same problem here.

jessicakoh’s picture

+

vegantriathlete’s picture

Yeah, it seems like changing and saving anything results in the error.

krisis’s picture

I can report getting the same error, right after enabling the modules delta (and ctools for dependency) and theme omega.

This happens due to a wrong call to delta_reduce() by function presave() in the delta_injection plugin. This function performs a variable_get on 'theme_omega_settings' which holds a value of 'N;'. This hardly qualifies as an array value when unserialized (actually giving NULL), which is expected by delta_reduce(). This issue might be omega theme related, maybe not initializing it's default values correctly?

After saving the Omega theme settings for the first time, the variable holds actual array values and the error disappears.

By setting the optional default value in variable_get as 'array()', this problem disappears also (obviously), but I have no idea what impact this has on saving the values of your delta. I suspect, nothing gets saved untill it gets something to work with since the mode of the delta was DELTA_PRESERVE, I have not tested this with the other type.

hugovdberg’s picture

The same error occurs on my site when trying to update a delta from an omega subtheme in Preserve mode. In my case I didn't change the column numbers but wanted to toggle a custom style sheet (I need a number of color schemes with identical layout, only different colors).
Interesting thing is that I made changes to columns in another delta, although in override mode, without problem, so I guess the steps to reproduce should explicitly say in step 2: Create a new delta in preserve mode based on omega theme.

lolmaus’s picture

I've got the following error:

Recoverable fatal error: Argument 1 passed to delta_reduce() must be an array, null given, called in /var/aegir/platforms/drupal-7.14/sites/all/modules/delta/plugins/delta/delta_injection.inc on line 100 and defined in delta_reduce() (line 256 of /var/aegir/platforms/drupal-7.14/sites/all/modules/delta/delta.module).

This happens after creating a new Delta template, then editing it and disabling a couple of regions. The edit is not being saved, rendering Delta useless. :(

krisis’s picture

Just reinstall delta beta9, this error is not there. Also read my comment, if you save the theme settings first and then create a delta based on that theme, your problem should be solved in beta10.

hugovdberg’s picture

Can you please explain what kind of changes you made to your omega subtheme (I'm at least assuming your creating a delta against a subtheme not the base theme)? I do have settings saved for my omega subtheme, but created the delta before changing the subtheme, in that case your solution for beta10 seems not to work. I tried both changing the region configuration and toggling stylesheets (what the only purpose of the delta is in my case), neither solved the problem for me.
Also I just created a second delta and I still get the error. For the moment I'm not in a hurry as I still have to build the css for my omega subtheme, so I will stick to beta10 but I hope it will be fixed soon anyway.

krisis’s picture

Maybe I spoke a little too soon, but what I meant to say was:

The error you get, that is also posted in the issue itself, isn't displayed anymore and just returns you to the delta listing page when:

1. You enable the modules / themes involved (delta, omega)
2. You goto Appearance in the administration pages and click on settings at omega theme (or the theme you decide to use in step 4)
3. You save those settings. Maybe changing a value here and there, but that's not necessary, but handy for checking if it actually gets saved.
4. You create a new delta based on omega (or a subtheme, have not tried that, but hey: even a subtheme is just a theme)
5. You save the delta, after changing to taste, but that's also not necessary.
6. You should NOT get the error. I have NOT checked if the values are actually saved, but I suspect so.

Or if you have everything set up already, just execute steps 2, 3 and 5 and view the hopefully glorious result in 6.

So, conclusion: I'm not 100% sure it's solved with this order of actions ... but I don't get the error :)

7wonders’s picture

I can confirm that this happens also for me when using delta to override my omega subtheme in preserve mode. Editing it and changing to overide all values allows the save to happen without any error.

krisis’s picture

The only problem that really exists is the fact that the variable named 'theme_THEME_settings' in the table 'variable' does not hold a (correct) value, namely an array (serialized).

When you save the actual settings page of the theme you wish to use for a delta, these values get written to the variable if it was not done so in the first place. I've been monitoring the variable during completing the steps and it was not there until I saved the settings of the delta. I was purposely trying to reproduce the error, so I did not save the theme settings first. (steps 2 and 3 in #11)

[guessmode]
Does the delta_injection plugin act as a creator of settings, making the first set of settings for the theme of choice? Delta operates in preserve mode, and needs something to preserve upon. If it silently fails at that point, it then tries to save the delta settings, but gets nothing back because of the earlier fail.
[/guessmode]

DerekL’s picture

Same Issue.

angelinardo’s picture

After posting a similar issue (http://drupal.org/node/1643886) regarding the Delta pages I stumbled upon the solution which was in front of me the entire time! Dang!! I hate it when that happens. After much Googling and searching with no luck, I went back to the Delta page and changed one little setting, which solved my problem. So if anyway else encounters this issue that I just did I hope I this can save you hours of searching amongst other things. Go to the Delta Edit Template page and select "Override all values" under the Operation Mode section at the bottom of the page. This took it out of preserve mode and allowed me to turn off the debugging blocks and grid overlay without any error message, which is what 7wonders also confirmed.

krisis’s picture

Using OVERRIDE instead of PRESERVE is not at all a solution, merely a temporary solution to get going. There are other ways to fix / test, take a look at #11 for instance.

So it should be noted that the solutions mentioned in #15 and #12 are only bypassing this issue, because they are saving all delta values, not the ones that are changed based upon the previous settings. On sites with a lot of deltas this can become quite resource intensive and makes it difficult to maintain a set of 'global' settings that affect all deltas based upon a certain theme (which is the strong point of delta).

Look in answer #11, follow the steps and please test if this solves your problem while stilll in PRESERVE mode, thank you for your cooperation.

xalexas’s picture

Error still persists in beta10 in PRESERVE mode.

imevul’s picture

#11 does not work for me in beta10 (Preserve mode).

I had everything set up using beta9 and then updated to beta10 and tried steps 2, 3 and 5 on the existing delta. Still got the same error. Also tried creating a new delta (steps 2, 3, 4, 5) and the result is the same.

Overriding would probably work since I have so few deltas, but it feels like a bad workaround and I'd rather just go back to beta9 until we have a proper solution.

hugovdberg’s picture

I have been debugging this thing a little more and have discovered the following things:

When you insert the code below in the presave function in delta_injection.inc you get an array containing both arguments to delta_reduce, and the result of the delta_reduce function. I first tried without this third element and got two perfectly fine arrays leaving me wondering where the error came from. After I added the delta_reduce to the array I still got no error confusing me even further.

foreach($this->variables() as $variable) {
  $debug[$variable] = 
    array(
      'this->delta->settings' => $this->delta->settings[$variable],
      'variable_get' => variable_get($variable),
      'delta_reduce' => delta_reduce($this->delta->settings[$variable], variable_get($variable)));
}
die( '<pre>'.print_r($debug, true).'</pre>');

Then I realised perhaps presave is called more than once leading me to changing my debug code to use echo instead of die, and split the foreach loop to first show the arguments, and a second loop to show the delta_reduce (since using one loop gave an error while the second time presave is called so nothing was printed). There I got the clue why Krisis' solution did not work for me. The theme_omega_settings variable was a proper array, but a number of color_*_settings were not. Since I don't use the Delta Color module at the moment I disabled it and now the proposed solution in #11 does work.

To me it seems now that the culprit is actually in the Delta module, and not in the Omega theme or Delta Color module. I think the Delta module should create a delta disregarding whether the normal theme or color scheme is initialized or not. If they do not provide any settings the delta should just contain every setting since that's the difference between the delta and the base theme. Same goes for the color module.

Next we can argue on whether the restrictions on delta_reduce should be removed, and simply replace an incompatible value with an empty array in delta_reduce, or we change the call to delta_reduce such to something similar to this, which to me seems the best option:

$this->delta->settings[$variable] = delta_reduce(
  is_array($this->delta->settings[$variable]) ? $this->delta->settings[$variable] : array(),
  is_array(variable_get($variable)) ? variable_get($variable) : array());

With this code in place of line 100 of delta_injection.inc I can have the Delta Color module enabled and save delta's just as you would expect.

bright8’s picture

I can confirm that disabling the Delta Color module (#19 from hugovdberg) does eliminate this problem, so it's possible to save a delta correctly without getting the error and without switching to Override mode. I'm not sure if it's essential to re-save the parent sub-theme before attempting to save the delta - my sub-theme had already been saved fairly recently and in any case, if you have a sub-theme it must have been saved at some point otherwise it wouldn't exist.

Obviously this is no help if you need Delta Color AND have lots of deltas so need to operate in Preserve mode, but it seems a useful workaround for those of us who don't.

Anandyrh’s picture

I don't use delta color module, but still I face this problem.

after downgrading to 7.x-3.0-beta9 from 7.x-3.0-beta10 everything works fine for me.

krisis’s picture

Thanks for the clarification, hugovdberg, that was really helpful. I had not tried the delta_color module in this specific debugging, therefor we can say with more certainty the damage is done by the delta module, more specific: the delta injection plugin.

We can submit a patch for review after some debugging done on the actual values being saved in the database right after setting an empty array in the variable_get function as a default value. Would you like me to supply that patch for this thread?

kalman.hosszu’s picture

Status: Active » Needs review
FileSize
774 bytes

Hi,

I attached a patch based on comment 19. Please review and test is!

Kalman

Red Sky Tom’s picture

I was lead to this form based on the same error but it turned out in my case that I selected Alpha in the drop down list for theme when I should have been selecting my sub theme name.

hugovdberg’s picture

Red Sky Tom #24, in your case this error is most probably caused by the fact that the default alpha theme does not provide a theme_alpha_settings array since it not used directly and thus the delta_reduce function raises an error.
Applying the patch in post #23 should remove the error, although in your case it actually helped you discover you were building a delta against the wrong base theme ;-)

Kalman.hosszu, thanks for the patch!

izudaire’s picture

Same issue.

Patched worked fine for me! good job, Thanks!

kalman.hosszu’s picture

If the patch works well, you should set status the RTBC.

cjboranp’s picture

Patch worked for me as well. Thank you!

BBC’s picture

Thanks for the patch! Worked for me as well.

jerryitt’s picture

Patch works as expected.

hairqles’s picture

Status: Needs review » Reviewed & tested by the community

The patch works perfect. Thanks for your contribution!

Cellar Door’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Will get this rolled into an official release ASAP - Thanks everyone!

play4quarters’s picture

Thanks Angelinardo...this really did save me lots of time. VERY appreciated!

archietek’s picture

Had exact same problem using D7.14. Could not save delta config for Omega or Bartik. Hosted on GoDaddy. No patch command. Manually applied patch from kalman.hosszu #23. So far, works great.
Thank you very much!

Bizio’s picture

Subscribe: patch works fine (applied into "delta_injection.inc" of "Delta" module version 7.x-3.0-beta10)! We are waiting for new release now. :) Thanks.

nflowers1228’s picture

Having the same problem. Any idea when the upgrade with the patch will be available? I'm a non-developer and don't know how to apply a patch, so I'd like to just update the module. Thanks so much.

Bizio’s picture

FileSize
1.2 KB

Unzip the attached file (patched) and put it into "sites/all/modules/delta/plugins/delta".

Before, make a backup of original file "delta_injection.inc" for safety.

Ciao
Fabrizio

nflowers1228’s picture

Thanks that was very helpful. We applied it and it's working now.

lameei’s picture

I confirm that the patched file mentioned by Bizio on #37 is the solution.

Cellar Door’s picture

Status: Patch (to be ported) » Fixed

Patch committed.... Thanks everyone!

hildesheim’s picture

I am a "newbie" with ZERO dev experience but do my own thing for our guest house website. Currently D6 but moving it to 7 and decided on omega with delta etc. Have really struggled with distributions as errors not unlike the above are very frustrating and impossible to deal with for 'idiots' like me. Started having some success by building from scratch and adding modules as required that I saw in openenterprise (could never get the disto to work, but liked the packaged functionality). Was going to give up on everything when the above error came up but found this link.
WELL DONE, FOR THE FIRST TIME I COULD FOLLOW THE POSTS AND HELP MYSELF AND HAVE JUST CREATED A NEW 'TEMPLATE' WITH NO ERROR!!!!
Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

quantos’s picture

Following - in case this re-opens. ;-)
#37 worked for me too - thanks Bizio.

kurtfoster’s picture

I was getting this issue with no error message, Delta just would not save a config settings on any deltas. I believe this only happened following the update to drupal-7.19. This was fixed on on our dev server by increasing max_input_var to 1,000. This is fine in dev but I don't want that setting that high in prod. I am on drupal-7.19 and 7.x-3.0-beta11. Any ideas?