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

Review and potentially replace empty() checks for sdesc and ldesc #158

Open
lhsazevedo opened this issue Oct 5, 2024 · 1 comment
Open

Comments

@lhsazevedo
Copy link
Contributor

lhsazevedo commented Oct 5, 2024

This is a follow up to a comment in #154

Background

There are a few cases where empty() is used to check sdesc (short description) and ldesc (long description) values. We need to verify if these checks are appropriate, considering that empty() checks for both unset and falsey values (including empty strings and "0").

Objective

Review the current usage of empty() for sdesc and ldesc, and determine if more precise string comparisons can be used.

Affected Files and Lines

At the moment of writing, there are at least three occurrences:

if (empty($this->nfo[$this->currentid]["ldesc"])) {

if (empty($this->nfo[$this->currentid]["sdesc"])) {

empty($sdesc) ? $ldesc : $sdesc

Tasks

  1. Verify the current behavior:

    • Confirm how sdesc and ldesc are initialized and used in the codebase.
    • Determine if there are cases where these entries could be unset or contain intentional falsey "0".
  2. Based on findings, decide on the appropriate action:

    • If empty() is the correct check, document why it's appropriate in these cases.
    • If a more precise can be used, implement changes (e.g., using $var === "" for strict empty string checks).
  3. Ensure consistency across the codebase in how these variables are handled.

References


Feel free to provide updates and seek clarification if needed during the investigation and implementation process.

@cmb69
Copy link
Member

cmb69 commented Oct 5, 2024

Maybe we should employ some static analyzer for the code base (not only for this issue)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants