This module let admin set entity (Ex: Node) title length of an entity via form in back office.

Project link

https://www.drupal.org/project/entity_title_length

Git instructions

git clone --branch 8.x-1.x https://git.drupal.org/project/entity_title_length.git

PAReview checklist

https://pareview.sh/pareview/https-git.drupal.org-project-entity_title_l...

Comments

a.boutakaoua created an issue. See original summary.

a.boutakaoua’s picture

Status: Active » Needs review
saesa’s picture

Issue summary: View changes
avpaderno’s picture

Issue summary: View changes
Issue tags: -preview, -Security

Thank you for your contribution!
PAReview seems to have issues, at the moment, so I cannot add the PAReview checklist link as I would normally do.

Next, the reviewers will check the project code, and report here what needs to be changed.

avpaderno’s picture

Status: Needs review » Needs work
  /**
   * Change length of a varchar entity field with data.
   *
   * @param string $entity_type_id
   *   The entity type.
   * @param string $field_name
   *   The field name to change.
   * @param int $field_length
   *   The new length of the field, must be larger than the previous value.
   */
  public function setVarcharField($entity_type_id, $field_name, $field_length) {
    db_change_varchar_field($entity_type_id, $field_name, $field_length);
  }

Why isn't the code directly put in the service method?

db_change_varchar_field() is the wrong function name, for a module whose machine name is entity_title_length.

The module should also implement hook_entity_base_field_info_alter(). Without that, the node title field would always report a wrong value for its length (since it's not read from the database).

  public function validateForm(array &$form, FormStateInterface $form_state) {
    parent::validateForm($form, $form_state);
    // Validate form input.
    $values = $form_state->getValues();
    if (!is_numeric($values['title_length'])) {
      $form_state->setErrorByName('title_length', $this->t('This should be a number!'));
    }

  }

The validation handler doesn't correctly validate the title length, as it would accept negative numbers, 0, and values that are too high for the database engine. For example, in MySQL 5.0.2 (and earlier versions) a VARCHAR field cannot have more than 255 characters, while in MySQL 5.0.3 and later versions, it can have up to 65,535 characters. Other database engines could have other limits the module is not applying.

a.boutakaoua’s picture

Thank you for your reports;
We will see those modifications ASAP.

avpaderno’s picture

Issue summary: View changes

PAReview is working again.

a.boutakaoua’s picture

Hello,
Would you check again,
Thanks,

a.boutakaoua’s picture

Status: Needs work » Needs review
klausi’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me! Any reason why you only support the node entity type? Config schema is missing for your entity_title_length.config.

An automated phpunit test would be nice to ensure this works as designed. All minor things, no blockers.

a.boutakaoua’s picture

We think to support the other entities in the next releases,
Thanks, for your comment.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.