Thanks to visit codestin.com
Credit goes to github.com

Skip to content

dbutil->csv_from_result() method throws deprecation errors when processing rows that contain "empty" variables #4460

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

Closed
jcogs-design opened this issue Sep 11, 2024 · 0 comments · Fixed by #4817

Comments

@jcogs-design
Copy link
Contributor

jcogs-design commented Sep 11, 2024

Description of the problem
Passing result of a query to ee()->dbutil->csv_from_result().
Query rows contain values that are blank / empty as per image example:
image

When the "description" value in this row is processed, a deprecation warning is thrown by php.

Error Messages


Deprecated
str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

ee/legacy/database/DB_utility.php, line 187

Severity: E_DEPRECATED

Screenshots / Videos / Template Code
The lines giving the error (from line 184 of DB_utility.php)

        // Next blast through the result array and build out the rows
        foreach ($query->result_array() as $row) {
            foreach ($row as $item) {
                $out .= $enclosure . str_replace($enclosure, $enclosure . $enclosure, $item) . $enclosure . $delim;
            }
            $out = rtrim($out);
            $out .= $newline;
        }

Environment Details:

  • Version: 7.4.11
  • PHP Version 8.2

Possible Solution
wrap line containing str_replace() with test for $item != ""

TomJaeger added a commit that referenced this issue May 14, 2025
…t_deprecation

Resolved #4460 where deprecation error was shown when using one of PHP utility functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant