Create an IP Address datatype

Created on 20 December 2019, almost 5 years ago
Updated 22 March 2023, over 1 year ago

We had an ip_address datatype in D7, but no such type exists for D8.

✨ Feature request
Status

Fixed

Version

2.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    #6 seems fine but it is old and needed to be re-rolled to bring it up to current standards. Here is a new version of that same patch.

  • Status changed to RTBC almost 2 years ago
  • πŸ‡¨πŸ‡³China jungle Chongqing, China
    1. +++ b/src/Plugin/DataType/IpAddressData.php
      @@ -0,0 +1,39 @@
      + *   label = @Translation("Ip address"),
      

      IP address?

    2. +++ b/src/Plugin/DataType/IpAddressData.php
      @@ -0,0 +1,39 @@
      +  public function getIp4Address(): ?string {
      
      +++ b/src/TypedData/Type/IpAddressInterface.php
      @@ -0,0 +1,30 @@
      +  public function getIp4Address(): ?string;
      

      getIpV4Address()?

    3. +++ b/src/Plugin/DataType/IpAddressData.php
      @@ -0,0 +1,39 @@
      +  public function getIp6Address(): ?string {
      
      +++ b/src/TypedData/Type/IpAddressInterface.php
      @@ -0,0 +1,30 @@
      +  public function getIp6Address(): ?string;
      

      getIpV6Address()?

    4. +++ b/src/Plugin/Validation/Constraint/IpConstraint.php
      @@ -0,0 +1,25 @@
      + *   label = @Translation("Ip", context = "Validation"),
      

      IP?

    Otherwise RTBC +1

  • Status changed to Needs review almost 2 years ago
  • πŸ‡¨πŸ‡³China jungle Chongqing, China
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    #1: Thanks, I missed that.
    #2, #3: I don't know. Personally I would choose IPv4 and IPv6, because that is the canonical usage. But Drupal is different. I guess Drupal would demand IpV4 and IpV6, but I'm not sure. Do you really think Ipv4 and Ipv6 are better than (IPv4 and IPv6) or (IpV4 and IpV6)?
    #4: No. The Symfony validation class is named "Ip" so we're stuck with that.

  • πŸ‡¨πŸ‡³China jungle Chongqing, China

    #2, #3, I think it depends. If we treat IPv4/IPv6 as a word, then we can go with Ipv4/Ipv6. if we think it's two words -- IP + V4/V6, then it should be IpV4/IpV6,

    E.g.
    1. LinkedIn, it's a word, not Linked + In,
    2. WeChat, it's a word. Not We + Chat.

    I would treat IPv4/IPv6 as a word. That's why I prefer Ipv4/Ipv6

  • πŸ‡¨πŸ‡³China jungle Chongqing, China

    #4 + * label = @Translation("Ip", context = "Validation"),

    >#4: No. The Symfony validation class is named "Ip" so we're stuck with that.

    Sorry, it may be unclear. I meant changing Translation("Ip", context = "Validation"), to Translation("IP", context = "Validation"),. Not the class name.

  • πŸ‡¨πŸ‡³China jungle Chongqing, China

    If an acronym is used in a class or method name, make it CamelCase too (SampleXmlClass, not SampleXMLClass). [Note: this standard was adopted in March 2013, reversing the previous standard.]

    In addition to #2, #3, yes, we can not use getIPv4Address/getIPv6Address. See https://www.drupal.org/docs/develop/standards/php/object-oriented-code#n... β†’

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    OK, you have a good argument. I made the changes you suggested. I also added some text to a few documentation comments.

  • Status changed to RTBC over 1 year ago
  • πŸ‡¨πŸ‡³China jungle Chongqing, China

    To me, It's ready. @TR, thank you!

  • Status changed to Fixed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    Committed. Thanks!

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

Production build 0.71.5 2024