Menu link content should remain mandatory
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3531200. -->
Reported by: [grimreaper](https://www.drupal.org/user/2388214)
Related to !88
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>In UI Icons Menu, <a href="https://git.drupalcode.org/project/ui_icons/-/blob/1.1.x/modules/ui_icons_menu/ui_icons_menu.module?ref_type=heads#L53:">https://git.drupalcode.org/project/ui_icons/-/blob/1.1.x/modules/ui_icons_menu/ui_icons_menu.module?ref_type=heads#L53:</a></p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #007700">function </span><span style="color: #0000BB">ui_icons_menu_entity_base_field_info_alter</span><span style="color: #007700">(array &</span><span style="color: #0000BB">$fields</span><span style="color: #007700">, </span><span style="color: #0000BB">EntityTypeInterface $entity_type</span><span style="color: #007700">): </span><span style="color: #0000BB">void </span><span style="color: #007700">{<br> ...<br> </span><span style="color: #FF8000">// Icon is always optional.<br> </span><span style="color: #0000BB">$fields</span><span style="color: #007700">[</span><span style="color: #DD0000">'link'</span><span style="color: #007700">]-></span><span style="color: #0000BB">setRequired</span><span style="color: #007700">(</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">);<br>}<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>It removes the required on the link itself and then you get <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/sobki_profile_bootstrap/issues/3531052" title="Status: Closed (fixed)">#3531052: Fatal error when the link in a menu item is empty</a></span>:</p>
<pre>Error: Call to a member function getUrl() on null in Drupal\menu_link_content\Entity\MenuLinkContent->getUrlObject() (line 104 of core/modules/menu_link_content/src/Entity/MenuLinkContent.php).</pre><p>If you try to save a link with empty URI.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Link should remain required while icon optional.</p>
> Related issue: [Issue #3531052](https://www.drupal.org/node/3531052)
issue