Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Discrepancy in StringLength/Max Validator Behavior Between Local Environment and Source Code (phalcon 5.7.0) #16662

Open
fedachkaa opened this issue Nov 8, 2024 · 1 comment
Labels
bug A bug report status: unverified Unverified

Comments

@fedachkaa
Copy link

Describe the bug
I'm encountering a discrepancy in the behavior of the StringLength validator between my local environment and my test server.

It seems that on the local environment, the validation fails when strlen() >= max, while on the test server, it fails when strlen() > max (with includedMaximum set to false).

To Reproduce

  1. Use the Phalcon\Validation\Validator\StringLength validator with the following configuration:
$validator->add('hash', new \Phalcon\Validation\Validator\StringLength\Max([
    "max" => 32,
    "messageMaximum" => "Field hash must be less than 32 characters"
]));
  1. Set includedMaximum to false (default behavior).
  2. Validate an MD5 hash (which is always exactly 32 characters long).

Expected Behavior:
Since "includedMaximum" is false, validation should pass for strings with up to 32 characters and fail for 33 characters, according to the source code.

Observed Behavior:
Local Environment: Validation fails for a 32-character hash.
Test Server: Validation passes for a 32-character hash, which matches the expected behavior.

Part of Dockerfile with installing Phalcon for local:

RUN git clone --branch v5.7.0 --depth=1 https://github.com/phalcon/cphalcon.git /usr/local/src/cphalcon && \
    cd /usr/local/src/cphalcon/build && \
    ./install && \
    mkdir -p /etc/php/mods-available/ && \
    echo "extension=phalcon.so" > /etc/php/mods-available/phalcon.ini && \
    echo "extension=phalcon.so" > /usr/local/etc/php/conf.d/docker-php-ext-phalcon.ini

Part of source code of Max.zep from docker:
image

I have confirmed that the source code in both environments is the same. This behavior difference suggests a possible environment-specific issue or bug in the Max validator logic for the StringLength validator.

Details for both environments

  • Phalcon version: (5.7.0)
  • PHP Version: (8.3.13)
@fedachkaa fedachkaa added bug A bug report status: unverified Unverified labels Nov 8, 2024
@raicabogdan
Copy link

this was fixed in issue #16643 I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: unverified Unverified
Projects
None yet
Development

No branches or pull requests

2 participants