Book allows emptying node titles in admin/content/book/* (Notice: Trying to get property of non-object in node_page_title)
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #1169576. -->
Reported by: [eric_a](https://www.drupal.org/user/344430)
Related to !24
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p><code>admin/content/book/*</code> page allows editors to update the book titles etc.<br>
On this page if node title is not set, it still allows to save the book pages form.<br>
Because of that, node title becomes empty and thows following errors</p>
<pre>The website encountered an unexpected error. Please try again later.</br></br><em class="placeholder">Drupal\Core\Entity\EntityStorageException</em>: SQLSTATE[23000]: Integrity constraint violation: 1048 Column &#039;title&#039; cannot be null: INSERT INTO {node_field_data} (nid, vid, type, langcode, status, title, uid, created, changed, promote, sticky, revision_translation_affected, default_langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12); Array<br>(<br> [:db_insert_placeholder_0] =&gt; 12<br> [:db_insert_placeholder_1] =&gt; 53<br> [:db_insert_placeholder_2] =&gt; book<br> [:db_insert_placeholder_3] =&gt; en<br> [:db_insert_placeholder_4] =&gt; 1<br> [:db_insert_placeholder_5] =&gt; <br> [:db_insert_placeholder_6] =&gt; 0<br> [:db_insert_placeholder_7] =&gt; 1502214772<br> [:db_insert_placeholder_8] =&gt; 1502619299<br> [:db_insert_placeholder_9] =&gt; 0<br> [:db_insert_placeholder_10] =&gt; 0<br> [:db_insert_placeholder_11] =&gt; 1<br> [:db_insert_placeholder_12] =&gt; 1<br>)</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<p>- Create a book and visit the edit page at "admin/content/book/{book_id}"<br>
This page lists all the child pages/chapers in the book where we can re-arrange or change title for the page.<br>
- Give the empty tile for the any node.<br>
- It still allows editors to submit the form with empty title.<br>
- Actually, title field is node title, so we should ensure that it is not empty.<br>
- If left empty, it will throw the errors mentioned above. </p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>- Add validation constraints on the form to validate if title is not empty.<br>
- Add other necessary validation in place.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<p>- Fix is implemented.<br>
- Added test cases.</p>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>N/A</p>
<h3 id="summary-api-changes">API changes</h3>
<p>N/A</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>N/A</p>
<h3 id="summary-release-notes">Release notes snippet</h3>
<p>N/A</p>
issue