Problem/Motivation

On a project, we are defaulting domain path pathauto to on, and completely disabling global pathauto. Unfortunately, since the state is either set to TRUE or empty (NULL), there is no way to persist a disabled state.

Steps to reproduce

  • Add a form alter to default domain pathauto to enabled using this logic
        $enabled = $this->domainPathautoGenerator->domainPathPathautoGenerationIsEnabled($this->node, $domain_id);

        if ($enabled === FALSE) {
          $this->form['path']['widget'][0]['domain_path'][$domain_id]['pathauto']['#default_value'] = TRUE;
        }
  • Now uncheck the pathauto checkbox for a domain and add a custom alias
  • Since the state record is now deleted, the above form alter will re-check the pathauto box and wipe out the custom alias

Proposed resolution

Store the 0 state (like pathauto does). It actually looks like this was the original intent given the logic in DomainPathautGenerator::domainPathPathautoGenerationIsEnabled()

    $collection = $this->getDomainPathPathautoStateCollection($entity, $domain_id);
    $value = \Drupal::keyValue($collection)->get($entity->id());
    if($value === NULL) {
      return FALSE;
    }
    return $value;

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 3198808-02.patch665 bytesjhedstrom

Comments

jhedstrom created an issue. See original summary.

jhedstrom’s picture

Status: Active » Needs review
StatusFileSize
new665 bytes
shenzhuxi’s picture

Status: Needs review » Postponed (maintainer needs more info)

If the state is empty, will it cause any problem?

BTW, the latest 8.x-1.x-dev added an new option "Hide the default URL alias UI" which will avoid to store anything to the global pathauto while keep use the global pathauto pattern for domain_path alias.

mably’s picture

Unless new, valuable information is provided, this issue will be closed in a few weeks.

mably’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Problem is fixed in latest 2.0.0-alpha5 release.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.