Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've added the google_appliance module to an installation profile. When the installation profile finishes and I click through to see the newly finished homepage, I'm presented with the following error:
Notice: Uninitialized string offset: 0 in google_appliance_block_view_alter() (line 310 of /sites/all/modules/contrib/google_appliance/google_appliance.module).
Comment | File | Size | Author |
---|---|---|---|
#3 | google_appliance-fix_block_visibility_defaults-1698202-3.patch | 1.6 KB | mpgeek |
Comments
Comment #1
mpgeek CreditAttribution: mpgeek commentedMerging issues here.
That's from #1700536: Notice: Uninitialized string offset: 0 in google_appliance_block_view_alter() appears on every page after installing the module ... It turns out that using an empty string for a default settings value that is meant to be an empty array at the start is causing problem. Patch coming soon.
Comment #2
mpgeek CreditAttribution: mpgeek commentedMarked #1700536: Notice: Uninitialized string offset: 0 in google_appliance_block_view_alter() appears on every page after installing the module as duplicate.
Comment #3
mpgeek CreditAttribution: mpgeek commentedI wasn't able to reproduce the error in any of my dev environments, but i did notice that after installation the array key's value is an empty string (instead of an empty array), and depending upon your PHP version
isset()
behaves a bit differently (note the "isset() on String Offsets") here: http://us2.php.net/manual/en/function.isset.php).Anyways, a patch is attached that should fix that.
Comment #4
mpgeek CreditAttribution: mpgeek commentedCommitted to dev: http://drupalcode.org/project/google_appliance.git/commit/3e8f763.
@Damien @Ari, do either of you have time to try this out and post back here whether or not this fixes issues you experienced? Thanks.
Comment #5
iamEAP CreditAttribution: iamEAP commentedHmm. Thought I'd covered this case in my patch, but I guess not. The variable handling code this module uses is pretty clever, but its weakness is in handling non-scaler variable data. Maybe eventually, we'll want to move away from storing these block visibility settings in a variable and throwing them into their own table (or appending them to the the block table), but the above patch looks like the best compromise for now.
Maybe the
if ($settings['block_visibility_settings'] == '')
should be....
if ($settings['block_visibility_settings'] === '')
Comment #6
mpgeek CreditAttribution: mpgeek commentedI only noticed that in fact isset() was trying to index into a string upon fresh install, but it still worked in my environments. Going to wait for reports from Damien and Ari to see if it actually fixes it, as I cannot reproduce the error.
Comment #7
DamienMcKennaThe current -dev codebase no longer has the error.
Comment #8
mpgeek CreditAttribution: mpgeek commented@DamienMcKenna, thanks for the feedback. Stable 7.x-1.8 has been pushed: http://drupal.org/node/1703058.