3535052 Deprecated function: ctype_digit()

Created on 8 August 2025, 2 months ago

Problem/Motivation

Fix introduced in 🐛 Deprecated function: ctype_digit() Active

Does not solve all the possible scenarios and the deprecation notice is still happening.

In our scenario, we have a view /foo/arg_0, where the empty arg lists all the possible items.

When accessing to /foo, we got the ctype_digit warning.

Values retrieved in line 101 are: Array
(
[0] => view_id
[1] => display_id
[2] => arg_0
)

but $lastSegment is NULL because $arg_0 route argument is not set.

Then, we get the deprecation error.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇪🇸Spain plopesc Valladolid

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @plopesc
  • Pipeline finished with Success
    2 months ago
    #568146
  • 🇪🇸Spain plopesc Valladolid
  • heddn Nicaragua

    Can we update the tests to cover this edge case?

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 1 month ago
    Total: 136s
    #587578
  • Pipeline finished with Failed
    about 1 month ago
    Total: 175s
    #591195
  • Pipeline finished with Success
    about 1 month ago
    Total: 214s
    #591208
  • 🇳🇮Nicaragua jeremy1606

    I have added a kernel test to validate the fix applied in UrlPath.php, where the original condition was modified to avoid a deprecation warning when calling ctype_digit() with a NULL value. The new conditional first checks that $lastSegment is not empty before applying ctype_digit(), which resolves the reported issue when accessing a view such as /foo without the arg_0 parameter. To ensure that the plugin behaves correctly in all scenarios, I created the file tests/src/Kernel/NullUrlPathArgumentTest.php with two tests: testNullLastSegment, which simulates a path with arg_0 = NULL and confirms that the plugin returns an empty string without errors; and testNumericSegment, which verifies that a numeric argument such as ‘123’ is handled correctly and returned as is. Both tests pass successfully and confirm that the plugin now works safely and robustly. If further work is needed, I welcome comments and suggestions.

  • heddn Nicaragua

    The test only changes didn't fail. So that means it isn't testing the issue or it would fail. NW

Production build 0.71.5 2024