Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ytemplates/bootstrap/value.custom_link.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$buttonId = $counter;
$categoryId = 0;
$name = $this->getFieldName();
$value = htmlspecialchars($this->getValue());
$value = htmlspecialchars($this->getValue() ?: '');
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Find the file and check its content
find . -name "MFormItem*" -o -name "*MFormItem*" | head -20

Repository: FriendsOfREDAXO/mform

Length of output: 137


🏁 Script executed:

# Search for MFormItem class definition to verify return type
rg "class MFormItem" -A 30

Repository: FriendsOfREDAXO/mform

Length of output: 4629


🏁 Script executed:

# Look at the file in question
cat -n ytemplates/bootstrap/value.custom_link.tpl.php

Repository: FriendsOfREDAXO/mform

Length of output: 1880


🏁 Script executed:

# Check git history to see the original code before this change
cd . && git log --oneline -20 -- ytemplates/bootstrap/value.custom_link.tpl.php 2>/dev/null || echo "Git history not available"

Repository: FriendsOfREDAXO/mform

Length of output: 105


🏁 Script executed:

# Search for getValue() method definition in MFormItem
rg "public.*function getValue" -B 2 -A 5

Repository: FriendsOfREDAXO/mform

Length of output: 868


🏁 Script executed:

# Get the actual git diff to see what changed
git show 5083a1c -- ytemplates/bootstrap/value.custom_link.tpl.php 2>/dev/null || git diff HEAD~1 -- ytemplates/bootstrap/value.custom_link.tpl.php 2>/dev/null || echo "Cannot retrieve git diff"

Repository: FriendsOfREDAXO/mform

Length of output: 2239


🏁 Script executed:

# Search for where this template is used or rendered
rg "value.custom_link.tpl.php" -B 3 -A 3

Repository: FriendsOfREDAXO/mform

Length of output: 562


🏁 Script executed:

# Check if there are any tests or usage examples
find . -name "*custom_link*" -type f | head -20

Repository: FriendsOfREDAXO/mform

Length of output: 269


🏁 Script executed:

# Look at the rex_var_custom_link widget to understand what it expects
rg "class rex_var_custom_link" -A 20

Repository: FriendsOfREDAXO/mform

Length of output: 1504


🏁 Script executed:

# Search for getWidget method to understand the expected $value parameter
rg "function getWidget" -B 2 -A 15

Repository: FriendsOfREDAXO/mform

Length of output: 3299


🏁 Script executed:

# Check if this file existed before in a different location or was completely new
git log --all --full-history -- ytemplates/bootstrap/value.custom_link.tpl.php | head -20

Repository: FriendsOfREDAXO/mform

Length of output: 827


🏁 Script executed:

# Check the field definition for custom_link to see if it's multi-value
rg "custom_link" -B 3 -A 10 | grep -A 10 "class.*custom_link\|type.*custom_link" | head -40

Repository: FriendsOfREDAXO/mform

Length of output: 3152


🏁 Script executed:

# Check if arrays are ever actually passed to this template by looking at how MFormItem is populated for custom_link
rg "custom_link" lib/yform/value/ -B 2 -A 10

Repository: FriendsOfREDAXO/mform

Length of output: 4099


🏁 Script executed:

# Check the classic template version to see if it has similar code
cat -n ytemplates/classic/value.custom_link.tpl.php

Repository: FriendsOfREDAXO/mform

Length of output: 1948


🏁 Script executed:

# Check if classic template also has the same issue and when it was last touched
git log --oneline -- ytemplates/classic/value.custom_link.tpl.php | head -10

Repository: FriendsOfREDAXO/mform

Length of output: 105


🏁 Script executed:

# Verify the actual differences between bootstrap and classic templates
diff -u ytemplates/classic/value.custom_link.tpl.php ytemplates/bootstrap/value.custom_link.tpl.php | head -30

Repository: FriendsOfREDAXO/mform

Length of output: 1285


🏁 Script executed:

# Check if custom_link value field is defined as multi-value or single-value
rg "db_type.*text" lib/yform/value/custom_link.php -B 5 -A 2

Repository: FriendsOfREDAXO/mform

Length of output: 470


Moin Verwende Null-Coalescing statt Elvis-Operator und aktualisiere auch classic-Template

Die Änderung mit ?: '' funktioniert zur Vermeidung des Deprecation-Warnings, aber ?? wäre die bessere Wahl. Der Elvis-Operator ?: behandelt alle falsy Werte gleich (z.B. 0 wird zu ''), während ?? nur null abfängt. Für ein Link-Feld ist 0 zwar keine typische Eingabe, aber ?? ist semantisch präziser:

-$value = htmlspecialchars($this->getValue() ?: '');
+$value = htmlspecialchars($this->getValue() ?? '');

Zusätzlich: Das ytemplates/classic/value.custom_link.tpl.php-Template hat das identische Problem und wurde nicht aktualisiert. Die gleiche Änderung sollte dort ebenfalls vorgenommen werden.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$value = htmlspecialchars($this->getValue() ?: '');
$value = htmlspecialchars($this->getValue() ?? '');
🤖 Prompt for AI Agents
In ytemplates/bootstrap/value.custom_link.tpl.php around line 6, the code uses
the Elvis operator ($this->getValue() ?: '') which converts all falsy values
(e.g. 0) to an empty string; change this to use the null-coalescing operator
($this->getValue() ?? '') so only null falls back to ''. Also apply the
identical replacement in ytemplates/classic/value.custom_link.tpl.php at the
corresponding line to keep both templates consistent.

$parameters = [
'media' => (1 == $this->getElement('media')),
'mailto' => (1 == $this->getElement('mailto')),
Expand Down