Warning when creating fields in contet types

Created on 8 April 2025, 10 days ago

Problem/Motivation

I was creating a field in a content type which has a body field that is being validated by Copyscape for copyrighted content (you can do this at /admin/config/copyscape/content), and I got this warning:

Steps to reproduce

Please read the steps below to reproduce the issue

Proposed resolution

Check for empty parameters in the copyscape_form_field_config_edit_form_alter() hook function

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇨🇦Canada danrod Ottawa

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @danrod
  • 🇨🇦Canada danrod Ottawa

    I'm also seeing this issue when creating a new content type and adding any field type.

    The fix is to check if $currentPath contains the string /admin/structure/types/manage/ if so, just add a return instruction and not execute the rest of the hook function:

    /**
     * Implements hook_form_FORM_ID_alter().
     */
    function copyscape_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
      $currentPath = \Drupal::service('path.current')->getPath();
      $pathParts = explode('/', $currentPath);
      $lastPart = $pathParts[count($pathParts) - 1];
    
      [$entityType, $bundle, $field] = explode('.', $lastPart);
    
      if ($entityType !== 'node') {
        return;
      }
    
      /** @var \Drupal\copyscape\Copyscape\Utility $utility */
      $utility = \Drupal::service('copyscape.utility');
      $fieldChecked = $utility->isCopyscaped($bundle, $field);
    
  • 🇨🇦Canada danrod Ottawa

    I added the condition in the MR https://git.drupalcode.org/project/copyscape/-/merge_requests/11 and it seems to have fixed the issue, I'll move it to "Needs Review", any novice user wants to test this?

  • 🇨🇦Canada danrod Ottawa
  • 🇨🇦Canada danrod Ottawa

    I'll move it to "Fixed" since it's a small change, if there's questions, please let me know and I'll re-open the task.

  • 🇨🇦Canada danrod Ottawa
Production build 0.71.5 2024