Book allows emptying node titles in admin/content/book/* (Notice: Trying to get property of non-object in node_page_title)

Created on 26 May 2011, over 13 years ago
Updated 4 September 2024, 3 months ago

Problem/Motivation

admin/content/book/* page allows editors to update the book titles etc.
On this page if node title is not set, it still allows to save the book pages form.
Because of that, node title becomes empty and thows following errors

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
(
    [:db_insert_placeholder_0] =&gt; 12
    [:db_insert_placeholder_1] =&gt; 53
    [:db_insert_placeholder_2] =&gt; book
    [:db_insert_placeholder_3] =&gt; en
    [:db_insert_placeholder_4] =&gt; 1
    [:db_insert_placeholder_5] =&gt; 
    [:db_insert_placeholder_6] =&gt; 0
    [:db_insert_placeholder_7] =&gt; 1502214772
    [:db_insert_placeholder_8] =&gt; 1502619299
    [:db_insert_placeholder_9] =&gt; 0
    [:db_insert_placeholder_10] =&gt; 0
    [:db_insert_placeholder_11] =&gt; 1
    [:db_insert_placeholder_12] =&gt; 1
)

Steps to reproduce

- Create a book and visit the edit page at "admin/content/book/{book_id}"
This page lists all the child pages/chapers in the book where we can re-arrange or change title for the page.
- Give the empty tile for the any node.
- It still allows editors to submit the form with empty title.
- Actually, title field is node title, so we should ensure that it is not empty.
- If left empty, it will throw the errors mentioned above.

Proposed resolution

- Add validation constraints on the form to validate if title is not empty.
- Add other necessary validation in place.

Remaining tasks

- Fix is implemented.
- Added test cases.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

🐛 Bug report
Status

Needs work

Version

2.0

Component
Book 

Last updated 5 days ago

Created by

🇳🇱Netherlands Eric_A

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024