Unhandled Warning: Undefined array key "translatable"

Created on 13 May 2024, about 1 year ago

Problem/Motivation

When enabling translation with Scheduler enabled, the site may throw an error:

Warning: Undefined array key "translatable" in _scheduler_translation_validate() (line 732 of .../docroot/modules/contrib/scheduler/scheduler.module)

This seems to be due to an assumption that the translatable option will exist when it may not. This seems identical to the issue in πŸ› Unhandled Warning: Undefined array key "translatable" Fixed .

Steps to reproduce

Enable translation on a site with Scheduler already installed.

Proposed resolution

Check if $options['translatable'] exists before using it.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States froboy Chicago, IL

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

Merge Requests

Comments & Activities

  • Issue created by @froboy
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    237 pass
  • Pipeline finished with Success
    about 1 year ago
    Total: 615s
    #171761
  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States froboy Chicago, IL
  • Status changed to RTBC about 1 year ago
  • πŸ‡ΊπŸ‡¦Ukraine podarok Ukraine

    can ne merged/tagged

  • First commit to issue fork.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    237 pass
  • This fix works for me. Thank you. :)

  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    JSchref, did you mean to erase the issue summary?

    I need to check the steps to reproduce, and it would be good to have test coverage for this, as clearly there are some incorrect assumptions in the code.

  • Status changed to Needs work about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    I have reverted JSchref erasing of the issue summary.

    I followed the 'steps to reproduce' but could not get the error. Specifically what I did was

    1. Enable Scheduler
    2. Enable "Content Translation" core module
    3. Add a new language via /admin/config/regional/language (Config -> Region and Language -> Language )
    4. Enable a content type for translation content (via Content type -> edit -> language settings -> tick both chekcboxes "Show language selector on create and edit pages" and "enable translation"
    5. Save is OK, no error
    6. Or if you enable you enable translation on admin/config/regional/content-language (Config -> Region and Language -> Content language and translation) - there is still no problem and no error on save

    I am not saying that there is no problem, it is just that there must be something else in your set-up which is causing this error. I need to understand what is causing the problem and replicate it, before committing any fix.

  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    On πŸ› Undefined array key "translatable" in _scheduler_translation_validate() (line 732 of modules/contrib/scheduler/scheduler.module) Active I was able to replicate the error, the key difference is that Language needs to be installed but not Content Translation. I am going to see if I can add some simple test coverage for this.

  • πŸ‡¬πŸ‡§United Kingdom jonathan1055

    I have added a simple test to make sure the Content Language form can be saved even when the Translation module is not enabled.
    https://git.drupalcode.org/project/scheduler/-/pipelines/393018
    The "test only changes" job shows that we do now have coverage for this, because the new test fails when the fix is reverted.

  • Status changed to Needs review 3 days ago
  • πŸ‡²πŸ‡¦Morocco c.lompole

    I continue to get the same warning with the test scenario initially mentioned in the description of this issue. I'm using version 2.2.1 and I'm getting the following error:

    Error message:

    Warning: Undefined array key "translatable" in _scheduler_translation_validate() (line 753 of modules/contrib/scheduler/scheduler.module).

    I created a local patch by replacing this condition:

    if ($options['translatable'] && ($enabled['publish_on'] || $enabled['unpublish_on'])) {

    with:

    if (isset($options['translatable']) && ($enabled['publish_on'] || $enabled['unpublish_on'])) {

    This checks if the "translatable" key exists before accessing it.

Production build 0.71.5 2024