Needs work
Project:
Features
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
18 Oct 2011 at 09:56 UTC
Updated:
5 Mar 2021 at 09:11 UTC
Jump to comment: Most recent, Most recent file
Hello,
Currently, call to image_style_delete() generates "Undefined index: isid dans image_style_delete()" notices if the reverted image style has not been overrided.
This is caused by the fact that loaded image_style array has no isid key, because image.module didn't gave it.
I suggest not to trying to erase an image_style if it has no isid.
Regards,
David
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | delete-image-style-only-if-it-exists-in-database-1313006-9.patch | 1.06 KB | leendertdb |
| #2 | features.1313006.2.patch | 1.35 KB | jamsilver |
| #1 | features_image_style_delete-1313006-1.patch | 643 bytes | David Stosik |
Comments
Comment #1
David Stosik commentedComment #2
jamsilver commentedSlightly expanding the issue here - but also I think features needs to pass a second parameter to image_style_delete. If none is passed then all field image formatters that used the image_style get their image_style instance setting wiped out thanks to
image_image_style_delete().At the moment any features-revert-all which ends up reverting an image_style *after* reverting an image field which used it causes that image field to end up broken in the db, and the old feature Overridden once again.
I've added the second parameter to the patch.
Comment #3
mpotter commentedPatch applies and seems to solve the problem.
Comment #4
tim.plunkett' : ' is not valid English.
These comments sound like documentation of a hack, not a fix. If there needs to be a @todo, let's add one.
Comment #5
mpotter commentedClosing this for lack of activity. I believe this was already fixed, but please re-open this issue if you can reproduce it in the latest version.
Comment #6
core44 commentedI know this is an old thread, but for my setup this issue seems to have reared its head again. I'm using 7.x-2.11 on Drupal 7.65. with the following snippet to revert any overridden features after running my install profile.
which is causing the following notice:
Notice: Undefined index: isid in image_default_style_revert() (line 1141 of Drupal/Sites/dev/modules/image/image.module).Think this issue may need reopening.
Comment #7
guypaddock commentedI, too, am seeing this issue on all of our sites during initial install. We are running a custom install profile that uses Features.
Comment #8
guypaddock commentedLooks like the culprit is here in core:
But since this issue is in the queue for features, perhaps the issue is that Features should not be calling this function if the style doesn't actually exist in the DB yet.
Comment #9
leendertdb commentedThis issue still affects the current 7.x-2.x version. It happened to one of our websites when trying to install a website from scratch based on an install profile which contains features. When this install profile runs it causes a lot of these messages:
I made a patch which applies to the current 7.x-2.x version. It adds a check to the
image_default_style_revert()method call which ensures theisidkey exists. If this key doesn't exist it means the style doesn't exist in the database (only in the code) and therefore the revert should not be called as it won't be able to do anything.See attached patch.
@mpotter, can you please re-open this issue? I can't as "Only maintainers can reopen".
Comment #10
mpotter commentedNormally you should just create a new issue rather than re-opening an old issue like this. But will make an exception in this case.
Comment #11
cboyden commentedWe've added this patch to our distribution; it fixes our problem with PHP notices when enabling a feature that includes an image style.
Comment #12
donquixote commentedThe patch might cause a regression.
Problem: Do we need to flush generated images?
image_default_style_revert() does two things:
image_style_flush($style).If the style is not stored in the database, we don't need to delete it from there.
However we might still want to flush the existing generated images.
The typical situation would be like this:
-> Image style is deleted in the database, only the code version is left.
-> If the old (database) version and the new (code) version are different, we need to clear generated images.
-> Image style was already not present in the database.
-> If the old (code) and new (code) version are different, we need to clear the generated images.
Clearing generated images is a costly operation on production, it means that images need to be regenerated afterwards.
It would be great if we could skip this, if the definition has not actually changed.
Proposed solution for this issue
Perhaps in this issue we should aim for a "minimal change" solution that fixes the problem but does not cause any regression.
This would be to call
image_style_flush()directly, instead of image_default_style_revert(), if the style has no style id.Perhaps the flushing might not be necessary in all cases, but this would be a separate problem that already exists in the current version.
Comment #13
donquixote commentedMore problems.
IMAGE_STORAGE_DEFAULT vs isset($style['isid'])
The function
image_features_revert()already contains a check for$style['storage'] != IMAGE_STORAGE_DEFAULT.Normally we should assume that if the storage is IMAGE_STORAGE_DEFAULT, then the style, at the time it was loaded (and written to the cache), was NOT stored in the database, but was coming from a module. In that case it does NOT have an 'isid'.
On the other hand, if 'storage' is something other than IMAGE_STORAGE_DEFAULT, then it DOES have an 'isid'.
This means, the check for 'isid' we are adding here is equivalent to the check for IMAGE_STORAGE_DEFAULT which is already there!
Under this assumption, the
elsebranch with its call toimage_default_style_revert()should be pointless.This else branch was added in #2148453: Image styles do not revert properly, commit 6e7c23b.
But so also need to take into account the cache in image_styles().
Can it happen that:
-> Normally not. When an image style gets deleted from the database via
image_default_style_revert(), the cache will be cleared.-> Normally not. When image style is updated in the database, the cache gets cleared.
-> Normally not. When an image style is written to the database, the cache gets cleared.
-> Yes! But only if you forgot to run
drush cc allafter the deployment.-> In this case, the
elsebranch ofimage_features_revert()will kick in on features revert.-> Yes! If you run
drush cc allbeforedrush fr, then none of the two operations will actually clear the generated images.This is some food for thought for whoever wants to work on this.
All of the above are conclusions I made from looking at the code. I did not actually test any of it.
Whoever wants to work on this should also check if my conclusions are correct!
Comment #14
lwalley commentedI added a patch in #3201779: Comparison of style effect in image_features_revert() might never be equal to fix the effect comparison for in code changes in the else condition which appeared to be causing in code image styles to be flushed on every feature revert. However, I agree with @donquixote's last comment, the else is only relevant for in code styles if the image styles cache is not cleared before running the feature revert; I ran a few feature reverts on in code changes with and without drush cc all.