Skip to content

N°9751 - Issue with AttributeImage in AttributeLinkedSetIndirect in portal#960

Open
accognet wants to merge 1 commit into
developfrom
feature/9751-AttributeImage_LinkedSet_portal
Open

N°9751 - Issue with AttributeImage in AttributeLinkedSetIndirect in portal#960
accognet wants to merge 1 commit into
developfrom
feature/9751-AttributeImage_LinkedSet_portal

Conversation

@accognet

@accognet accognet commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

internal

Copilot AI review requested due to automatic review settings July 6, 2026 13:22
@CombodoApplicationsAccount CombodoApplicationsAccount added the internal Work made by Combodo label Jul 6, 2026
@greptile-apps

greptile-apps Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a fatal PHP error when AttributeImage is rendered inside an AttributeLinkedSetIndirect in the portal, where $oHostObject can be null. The previous code called $oHostObject->IsNew() without a null guard, which would cause a PHP fatal error on null.

  • Adds is_null($oHostObject) as the first short-circuit condition in GetAttributeImageFileUrl, so method calls on $oHostObject are never reached when it is null.
  • When $oHostObject is null, the function now falls through to the inline base64 data path (the safe fallback), rather than crashing.

Confidence Score: 4/5

The change is a minimal, targeted null guard that prevents a fatal PHP error in a specific portal rendering context.

The null check is correctly placed as the first short-circuit condition, and the safe fallback (returning inline base64 data) is the right behavior when no host object is available. The only remaining concern is a cosmetic leftover comment from the refactored variable.

No files require special attention beyond the minor style nit in GetAttributeImageFileUrl.

Important Files Changed

Filename Overview
sources/Core/AttributeDefinition/AttributeImage.php Added null guard for $oHostObject in GetAttributeImageFileUrl to prevent a fatal PHP error when the host object is null in portal linked-set indirect contexts; a leftover inline comment (//$bExistingImageModified) from the old variable is still present.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["GetAttributeImageFileUrl(value, oHostObject)"] --> B{"value is object?"}
    B -- No --> C["return null"]
    B -- Yes --> D{"value isEmpty?"}
    D -- Yes --> C
    D -- No --> E{"oHostObject is null?"}
    E -- Yes --> F["return base64 inline data"]
    E -- No --> G{"oHostObject IsNew?"}
    G -- Yes --> F
    G -- No --> H{"oHostObject IsModified AND attribute in ListChanges?"}
    H -- Yes --> F
    H -- No --> I["return GetDisplayURL"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["GetAttributeImageFileUrl(value, oHostObject)"] --> B{"value is object?"}
    B -- No --> C["return null"]
    B -- Yes --> D{"value isEmpty?"}
    D -- Yes --> C
    D -- No --> E{"oHostObject is null?"}
    E -- Yes --> F["return base64 inline data"]
    E -- No --> G{"oHostObject IsNew?"}
    G -- Yes --> F
    G -- No --> H{"oHostObject IsModified AND attribute in ListChanges?"}
    H -- Yes --> F
    H -- No --> I["return GetDisplayURL"]
Loading

Reviews (1): Last reviewed commit: "N°9751 - Issue with AttributeImage in At..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash in AttributeImage::GetAttributeImageFileUrl() that occurred when the host object is null. The public GetAsHTML() method allows $oHostObject to default to null, but the previous code unconditionally called $oHostObject->IsModified() / IsNew() and later $oHostObject->GetKey(), causing a fatal error — notably for AttributeImage fields displayed inside an AttributeLinkedSetIndirect in the portal. The fix short-circuits to serving the image inline as a base64 data: URL when no host object is available.

Changes:

  • Add an is_null($oHostObject) guard to the condition so a missing host object returns the inline base64 data URL instead of dereferencing null.
  • Inline the former $bExistingImageModified local into the condition (keeping its intent as a trailing comment).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +169 to +172
if (is_null($oHostObject)
|| $oHostObject->IsNew()
|| ($oHostObject->IsModified() && array_key_exists($this->GetCode(), $oHostObject->ListChanges())) //$bExistingImageModified
) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants