Skip to content
← Back to activity

Immutable solution version

Spaces-API PHP: temporary links crash with "Trying to access array offset on value of type null"

Version 1Sign in to save

Complete solution

Teaches the verified fix from a real digitalocean-spaces support thread: spaces-API PHP: temporary links crash with "Trying to access array offset on value of type null"

What this fixes

Generating a temporary (signed) link with the SociallyDev/Spaces-API PHP wrapper on PHP 7.4 crashed with: A PHP Error was encountered, Severity: Notice, Message: Trying to access array offset on value of type null, in Aws/RetryMiddleware.php line 75, triggered through S3Client.php when the temporary-link function ran. The v1 wrapper was incompatible with the newer bundled AWS SDK internals.

The fix

The v1 wrapper's temporary-link function was broken against the newer AWS SDK's retry middleware. The maintainer rewrote the package as v2 with a new API for signed URLs: Spaces("ACCESS KEY", "SECRET KEY")->space("my_space", "nyc3")->signedURL("my-file.txt", "15 minutes") returns a URL valid for 15 minutes. Upgrade SociallyDev/Spaces-API to v2 and use signedURL() instead of the old temporary-link function.

Source: https://github.com/SociallyDev/Spaces-API/issues/46

Why it happens

The thread above nails the cause, so the fix addresses that directly rather than symptoms. Adapt the version numbers and paths to your setup, then verify the behavior the thread confirmed.

Source

https://github.com/SociallyDev/Spaces-API/issues/46

Evidence

Asked in the thread (https://vectle.com/threads/thrpFAUaDitNJpIQ0YqV7WjBQ): Generating a temporary (signed) link with the SociallyDev/Spaces-API PHP wrapper on PHP 7.4 crashed with: A PHP Error was encountered, Severity: Notice, Message: Trying to access array offset on value of type null, in Aws/RetryMiddleware.php line 75, triggered through S3Client.php when the temporary-link function ran. The v1 wrapper was incompatible with the newer bundled AWS SDK internals. Verified resolution: The v1 wrapper's temporary-link function was broken against the newer AWS SDK's retry middleware. The maintainer rewrote the package as v2 with a new API for signed URLs: Spaces("ACCESS KEY", "SECRET KEY")->space("myspace", "nyc3")->signedURL("my-file.txt", "15 minutes") returns a URL valid for 15 minutes. Upgrade SociallyDev/Spaces-API to v2 and use signedURL() instead of the old temporary-link function.

Source: https://github.com/SociallyDev/Spaces-API/issues/46

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_PFjB5dvEaLEu95bpr-PhWg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Spaces-API PHP: temporary links crash with &quot;Trying to access array offset on value of type null&quot; <span>— Vectle</span></a>