I've found an issue for multilingual site, when one module (ImageCahce) had no options definitions and it's values were translated (they're not suppose to be unless you define it). I was diging deeper and deeper and found the issue in handlers/base.inc, in unpack_options function. There is a code like this:
else if (!empty($definition[$key]['translatable']) && !empty($value)) {
$storage[$key] = t($value);
}
else {
$storage[$key] = $value;
}
If you have $definition[$key] equal to some string, the first expression will return TRUE and value will be translated. Initially I thought it's other module's bugs, but we could resolve it here just by adding additional check like this:
else if (is_array($definition[$key]) && !empty($definition[$key]['translatable']) && !empty($value)) {
$storage[$key] = t($value);
}
else {
$storage[$key] = $value;
}
I've attached patch to solve this.
Comments
Comment #1
neochief commented#751310: Imagecache + views + locale Here's linked issue form IC Profiles, which was the initiator of this.
Comment #2
andypostIf
$definition[$key]is a string so probably it has no key ['translatable']Comment #3
andypostConfirm the bug under php 5.2.12
returns
bla-bla<br/><br/>bComment #4
andypostPatch in right format
Comment #5
merlinofchaos commentedThis isn't really a bug in PHP, it's a side effect of type conversion.
When using [] notation on a string, this is array notation. It isn't a dictionary, like normal PHP arrays, so only integer values are allow. A string value gets converted to an integer. So you end up with:
This then returns the first letter of the string.
Now, this is really a bug in the other program, because the definition should not be a string. option_definition() in the base object documents this, but it's true that many people will not know to look there for this documentation.
That said, as of Views 3, invalid option_definitions() will be MORE problematic than they are now. Views 2 just saves and exports whatever it is given by the form, but Views 3 tries to be smarter, and it only saves/exports items that are properly defined in the option_definition().
So this fix would actually mask a problem that we would be better off warning the user about.
So I think at best we could check for this condition and provide a vpr() to warn the user/developer that the option_definition() is invalid.
Comment #6
dawehnerWhat about this.
Comment #7
dawehnerHere is a rerole. Fixed identiation, too.
Comment #8
merlinofchaos commentedSuch a tiny patch and it doesn't want to apply to 7.x either. Committed to D6, at least.
Comment #9
dawehnerReverted this patch
Comment #10
barraponto@dereine: please explain the reversion.
Comment #11
dawehnerNot sure the reason anymore but there was broken a lot of things as far as i remeber.
Comment #12
neochief commentedSo, what are the next steps?
Comment #13
dawehnerProvide a patch which doesn't brake everything?
Comment #14
neochief commentedCan you describe what "everything" is? Everything was working by the time this patch was commited and it's you who reverted it. I'd love to help with investigation, but it is not clear from which version it was reverted either.
Comment #15
dawehnerSorry i can't remember the reason, it's quite long ago.
But if a patch is reverted there is 100% a reason for this, not just a "small bug".
You might could test all parts where this is involved: looking at a view, editing a view, look at the export etc.
This wasn't against the patch, it makes sense but it definitive had a bug.
Comment #16
neochief commentedOkay, I'll do that, thanks.
Comment #17
kgoel commentedI tried to update from Views-2.x to Views-3.x on D6 (also using Imagecache module).
Got some errors in base.inc file - fatal error: cannot use string offset as an array in base.inc on line 146. Tried the patch in #7 and tested parts like edited view ,export, and save but didnt see anything unusual.
It has been long since the last comment on this issue so not sure about proceeding on this issue. Anyone?
Comment #18
mustanggb commented