Add option to add phone links for mobile use

Created on 6 April 2022, over 2 years ago
Updated 16 May 2024, 4 months ago

Problem/Motivation

I see a need to be able to add phone links for mobile use.

Proposed resolution

Add a phone number matcher.

Remaining tasks

Create a new phone matcher and add a patch or merge request.

✨ Feature request
Status

Needs review

Version

7.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States robertshell22

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • This is a good idea, but it needs work.

    • If I use 555-555-1234 and add a link to a phone number, it makes the link tel:+555-555-1234. Phone numbers without a country code should not have a + in front.
    • If I enter tel:555-555-1234, it still matches, but clicking the Phone match will make the link tel:+tel:555-555-1234, which is definitely broken. This can be fixed with:
        // Strip the tel: prefix to match only the phone part of the string.
        $string = str_replace('tel:', '', $string);
    
  • Using filter_var($string, FILTER_SANITIZE_NUMBER_INT) is a bad idea, and it's not used anywhere in Drupal code.
  • The code doesn't conform to Drupal coding standards.
  • Telephone links aren't only for mobile phones. A computer can define an action for the tel: prefix, such as calling from your computer with Skype or Signal. Maybe say Opens configured phone app to call @phone.
  • The matcher needs tests. Look at EmailMatcherTest.php for an example.
  • First commit to issue fork.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.4 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    Composer require failure
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    84 pass
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    84 pass
  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States hlopez

    I applied the requested changes to the patch and created an issue fork for it. I'm uploading the original interdiff for the tests and coding standards predating the issue fork. I also changed the branch to 6.1.x-dev due to issues with Jenkins initializing the 6.0.x testing suite.

  • Status changed to Needs work 10 months ago
  • You could probably use

    if (preg_match("/^[- +()0-9]+$/", $string) && (preg_match_all("/[0-9]/", $number) > 9)) {
    

    instead of

    if ((preg_match_all("/[- +0-9]/", $string) != FALSE) && (preg_match_all("/[0-9]/", $number) > 9)) {
    

    Allowing parentheses is important, at least.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    84 pass
  • Status changed to Needs review 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States hlopez

    I reverted the change, thanks @solideogloria

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 8 months ago
    83 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States jsutta United States

    I wasn't able to get a patch generated from the merge request to install, so I rolled a patch using the contents of the merge request. Posting it here in case anyone runs into the same issue. All that said, the functionality provided by the merge request works perfectly.

  • The last submitted patch, 11: 3273630-11.patch, failed testing. View results β†’
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Status changed to Needs review 8 months ago
  • Moving back to NR, since the prior patch is for installing locally, not for 6.1.x-dev.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 8 months ago
    83 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States jsutta United States

    Reposting yesterday's patch, targeted against the 6.1.x-dev branch. (Please let me know if I got this wrong, I'm still learning how to do this, and I'm happy to fix it so it's right.)

    I also checked the test failure and it appears to be related to line 178 in tests/src/FunctionalJavascript/LinkFieldTest.php:
    $assert_session->elementAttributeContains('xpath', '//article/div/div/div[2]/a', 'rel', "nofollow");

    Meaning the test failure isn't related to this change, but to another test. However, it's possible something in this change broke the test, so if needed I can look into it further.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 8 months ago
    83 pass, 2 fail
  • πŸ‡ΊπŸ‡ΈUnited States jsutta United States

    That's odd, I specifically picked 6.1.x-dev to test against, but somehow it got set to 6.1.x?

  • The last submitted patch, 14: 3273630-14.patch, failed testing. View results β†’
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • I assumed the branch selected was why the test was failing, but maybe I was wrong.

  • Were you trying to use the MR patch with the dev version of the module locally?

  • Status changed to Needs review 8 months ago
  • Don't bother posting a new patch file. The MR patch is the one that matters, as only MRs can be used with GitLab-CI.

  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson
  • Production build 0.71.5 2024