-
Notifications
You must be signed in to change notification settings - Fork 21
Update value.custom_link.tpl.php #388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Verhindert Deprecated: htmlspecialchars(): Passing null to parameter FriendsOfREDAXO#1 ($string) of type string is deprecated in redaxo\src\addons\mform\ytemplates\bootstrap\value.custom_link.tpl.php on line 6
|
Moin! 👋 WalkthroughEine einzelne Datei wurde angepasst, um die Wertezuweisung defensiver zu gestalten. Der Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ytemplates/bootstrap/value.custom_link.tpl.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
ytemplates/bootstrap/value.custom_link.tpl.php (1)
lib/MForm/DTO/MFormItem.php (1)
getValue(74-77)
| $categoryId = 0; | ||
| $name = $this->getFieldName(); | ||
| $value = htmlspecialchars($this->getValue()); | ||
| $value = htmlspecialchars($this->getValue() ?: ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Find the file and check its content
find . -name "MFormItem*" -o -name "*MFormItem*" | head -20Repository: FriendsOfREDAXO/mform
Length of output: 137
🏁 Script executed:
# Search for MFormItem class definition to verify return type
rg "class MFormItem" -A 30Repository: FriendsOfREDAXO/mform
Length of output: 4629
🏁 Script executed:
# Look at the file in question
cat -n ytemplates/bootstrap/value.custom_link.tpl.phpRepository: 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 5Repository: 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 3Repository: FriendsOfREDAXO/mform
Length of output: 562
🏁 Script executed:
# Check if there are any tests or usage examples
find . -name "*custom_link*" -type f | head -20Repository: 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 20Repository: FriendsOfREDAXO/mform
Length of output: 1504
🏁 Script executed:
# Search for getWidget method to understand the expected $value parameter
rg "function getWidget" -B 2 -A 15Repository: 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 -20Repository: 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 -40Repository: 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 10Repository: 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.phpRepository: 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 -10Repository: 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 -30Repository: 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 2Repository: 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.
| $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.
Verhindert Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in redaxo\src\addons\mform\ytemplates\bootstrap\value.custom_link.tpl.php on line 6
Summary by CodeRabbit
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.