Bunch of Undefined Array Warnings After Install

Created on 12 December 2024, 6 days ago

Problem/Motivation

Directly after installing there are a ton of Warning: Undefined array key "checkbox_field" in page_notifications_entity_presave() (line 107 type messages. I assume because the module is missing config, but it comes off as broken/bad code having them I think.

Steps to reproduce

1. Fresh site
2. Install module
3. See notices on /admin/modules?filter=page after install

Proposed resolution

Adjust code to hide warnings from users.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States NicholasS

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @NicholasS
  • πŸ‡ΊπŸ‡ΈUnited States NicholasS

    Ok now when trying to save /admin/page-notifications/tabs/default/second after install I got a

    The website encountered an unexpected error. Try again later.
    
    Error: Class "Drupal\page_notifications\Form\Drupal" not found in Drupal\page_notifications\Form\MessagesForm->submitForm() (line 265 of modules/contrib/page_notifications/src/Form/MessagesForm.php). call_user_func_array(Array, Array) (Line: 129) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 67) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 597)
    
  • πŸ‡ΊπŸ‡ΈUnited States NicholasS

    I love the idea of this module, but man.... I can't get it working and been browsing the code and its full of areas that need work, lots of unused variables and comment blocks. I assume maybe this was a custom module at one point? I am going to look over it for a few days and see if I have the capacity to refactor it.

    Any Maintainers want to chime in is this module useable in its current form? Seems not to be.

  • πŸ‡ΊπŸ‡ΈUnited States NicholasS

    #3 seems to be a cache issue, tried today and was able to save the configuration page,

    however it all seems hardcoded to full_html and our site had removed that text format. The dropdowns on the configure page allow me to select another format, but on each save it reverts back to full_html

  • πŸ‡ΊπŸ‡ΈUnited States risweb

    Thanks nicholass for looking into this. I will test the code soon and add new release.

  • πŸ‡ΊπŸ‡ΈUnited States NicholasS

    @risweb - Thanks for the module, I saw someone else brought up the custom entity type, instead of how its currently designed to use a node and fields to manage subscriptions. I am just curious has that been working out for your sites? It seems it would generate a lot of nodes, and playing around with the confirmation page such as /page-notifications/confirmation/XXXXXX/27956-node-XXXXXX seems a bot can spam that generating a lot of fake node/subscriptions.

    I am currently still looking at it all locally, but more I review I feel like this module needs a new 4.x release where a lot of it get refactored with good dependency injection, XXS and validation. Would that be something your open to supporting?

  • πŸ‡ΊπŸ‡ΈUnited States NicholasS

    I think I would be willing to refactor this in a 4.x branch and would propose the following: (Just from initial skim of code)

    • Increase Dependency Injection, removing static calls such as `\Drupal::`
    • Convert to a custom entity type, and provide migration path from nodes

      Use Drupal Config management for settings instead of the database to store module/templates, was there a reason for using the database I'm not aware of?

      Instead of fields being manually added, I think it should be more automatic, and really I think you just need a checkbox for the editor, and can use revision log message field for the short editor note? Id have to dive into more why you need a timestamp field.

      Various token/email validation improvements like token expiration, cron cleanup, also don't love the email in the address bar which would then show in server logs, I feel it could be an obscure ID that relates back to an email.

    Do you have any strong opinions on any of those?

Production build 0.71.5 2024