Fix/image variable#40
Merged
Merged
Conversation
ralflang
approved these changes
May 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix PHP 8
uniqid()type error in image form fieldsSummary
mt_rand()to string ingetRandomId()souniqid()receives a valid prefix on PHP 8+.ImageVariableclass and the legacyHorde_Form_Type_imageimplementation.Problem
On PHP 8.0+,
uniqid()requires its first argument ($prefix) to be a string. Both image field implementations call:mt_rand()returns anint, which triggers:This aborts form rendering whenever an existing image is loaded into the field — for example when Turba displays or edits a contact with a photo. The contact view fails entirely (left pane not rendered) because the exception is thrown while building the image input in
Horde_Form\V3\ImageVariable->getImage().Observed stack trace (Turba):
Solution
Cast the random prefix to string, preserving the original intent of adding entropy to the session key:
Changed in:
src/V3/ImageVariable.php—getRandomId()lib/Horde/Form/Type.php—Horde_Form_Type_image::getRandomId()Related work
The same
uniqid(mt_rand())pattern appears elsewhere in the framework (e.g.Horde_Config,Horde_Util,Horde_Core_Ui_VarRenderer_Html). Those call sites may need the same cast if they are hit on PHP 8+, but they are outside the scope of this image-field fix.Test plan
TypeErrorfromuniqid()in Horde logs when loading contacts with photos.