Notice: Undefined offset: 0 in Drupal\focal_point\Plugin\Field\FieldWidget\FocalPointImageWidget::process() (line 44 of /modules/focal_point/src/Plugin/Field/FieldWidget/FocalPointImageWidget.php).

Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "fid" for route "focal_point.preview" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 193 of /core/lib/Drupal/Core/Routing/UrlGenerator.php).

Visiting a edit form page which would normally display a focal point widget causes a WSOD with the above fatals.

Uninstalling focal point and crop API, then re-installing did not resolve the issue.

Reverting focal point to beta1 resolved the issue.

Site running on D8 8.1.7.

The entity form being is a node with just a few core provided field types, nothing special.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpi created an issue. See original summary.

bleen’s picture

I have tried several times to reproduce this ... can you reproduce this on more than one site?

bleen’s picture

This might be the same issue as #2782749: Crop not working on beta2 which I havent been able to reproduce.

Is there any chance that this is an issue with local cache? If you copy the image path (of an image that should have changed but didnt) and open it in a new tab in your browser with ?cachebuster=fgdkjhdgjdkfshgdfskjghfdjkggdfs appended to the URL, does the image suddenly look correct? (If there is already a ?itok=sdgkjhsdgkh then use an "&" instead of a "?" for the cachebuster)

justkristin’s picture

We are having this same error now when trying to edit a node that uses focal point for one of the images. If the problem is with crop, can we use focal point without it? It is less important than focal point itself...

justkristin’s picture

I was also able to make the fatal go away by backing up to beta1.

caldenjacobs’s picture

Same issue here. Downgrading to Beta1 fixed on my end as well.

bleen’s picture

Status: Active » Needs review
FileSize
1.46 KB

This patch will definitely fix the issue, but in those cases where the fid cannot be found the preview link will not appear.

bleen’s picture

I *still* cant seem to find any way to reproduce this issue .. can everyone plaese try to give me as much detail as possible to any customizations you might be making to the form where you are seeing this error so I can try to figure this out. Are your fields limited to 1 image or multiple? do you every manipulate form_state in a custom module anywhere? any weird hook form alters? Does this happen EVERY time you load the form or only on Tuesdays? Does it happen only when creating a new entity? Only when updating? Both?

Ideally, someone who is seeing this error and is using an IDE, please set a breakpoint point in FocalPointImageWidget::process and put the values of $item, and $element in a gist so I can see them.

We are having this same error now when trying to edit a node that uses focal point for one of the images. If the problem is with crop, can we use focal point without it? It is less important than focal point itself...

Just for the record, it's the preview functionality that is causing this, not the crop integration ...

bleen’s picture

Hmmm ... it looks like the issue *might* be that in some circumstance (I'm guessing based on another contrib module, or some config that I can't find anywhere) the upload widget that appears below any existing images has a "preview" in its element array for some reason.

Based on that, I think this is a safe solution. Please review....

dpi’s picture

Re-downloaded beta2, applied patch, the widget appears to be working again.

  • bleen committed f961ab5 on 8.x-1.x
    Issue #2784287 by bleen: focal_point fatals on attempt to view page...
bleen’s picture

Status: Needs review » Fixed
Scott Falconer’s picture

This happens for me if I have a default image set for the field. Remove the default image and the issue doesn’t occur. Patch in #9 resolves the issue.

bleen’s picture

Awesome.... Thanks for finally giving me a way to reproduce

dpi’s picture

I double checked both sites I constructed recently with focal_point, and there are no image fields with default images. Take that as you will...

agentrickard’s picture

Yes, confirming that this happens if the field has a default image set. In my case:

* Create user profile "picture" field with default image
* Save new account (with default image)
* Try to edit account -- error occurs.

It may be that the original account was created prior to the "preview" functionality being added to the module. I did do an update to beta2 this week. So the field may have been created with beta1, where the preview link doesn't exist, so no problem was reported.

bleen’s picture

Title: focal_point fatals on attempt to view page containing widget » fatal error when saving a form with an image widget that has a default image set

changing title in case people search for this later ...

also, I'm hoping to create a new release once I can get #2790809: Preview page return "Access Denied" when creating a new node settled ... hint, hint, nudge, nudge

Status: Fixed » Closed (fixed)

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