Skip to content

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

Closed

Description

@lhsazevedo

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.

Activity

  1. cmb69 commented on Oct 5, 2024

    @cmb69
    Member

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

  2. added a commit that references this issue on Feb 12, 2026
    59798af
  3. added a commit that references this issue on Feb 15, 2026
    4eb564e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions