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

utf8_encode Issue #678

Closed
ravimallya opened this issue Sep 24, 2023 · 2 comments · Fixed by #700
Closed

utf8_encode Issue #678

ravimallya opened this issue Sep 24, 2023 · 2 comments · Fixed by #700
Assignees

Comments

@ravimallya
Copy link

ravimallya commented Sep 24, 2023

Install php version 8.2 in a LAMP server and define WP_STATELESS_CONSOLE_LOG as true. You will receive the below error while uploading a image in 'stateless' mode after manual setup of the plugin:

Deprecated: Function utf8_encode() is deprecated in /var/www/html/wp-content/plugins/wp-stateless/lib/classes/class-logger.php on line 391
Deprecated: Function utf8_encode() is deprecated in /var/www/html/wp-content/plugins/wp-stateless/lib/classes/class-logger.php on line 391
Deprecated: Creation of dynamic property wpCloud\StatelessMedia\GS_Client::$key_json is deprecated in /var/www/html/wp-content/plugins/wp-stateless/lib/classes/class-gs-client.php on line 66
 PHP Warning:  Cannot modify header information - headers already sent in /var/www/html/wp-content/plugins/wp-stateless/lib/classes/class-logger.php on line 381

Also, I'm getting 404 errors for the images that I uploaded after setting up the plugin, and no images being displayed that I uploaded prior the activation of plugin as well as after I synced existing to cloud.

The `utf8_encode' is deprecated since PHP 8.2.0 and will be removed in PHP 9 PHP Watch.

This error can be fixed by replacing the below lines in /classes/class-logger.php on line 390:

  protected function _encode( $data ) {
    return base64_encode( utf8_encode( json_encode( $data ) ) );
  }

with:

  protected function _encode($data) {
    $utf8Data = json_encode($data);
    if ($utf8Data === false) {
        // Handle JSON encoding error
        return false;
    }
    $utf8Data = mb_convert_encoding($utf8Data, 'UTF-8', 'UTF-8');
    if ($utf8Data === false) {
        // Handle conversion error
        return false;
    }
    return base64_encode($utf8Data);
}
@planv planv added this to the v4.1.0 security improvements milestone Dec 19, 2023
@balexey88 balexey88 assigned planv and unassigned balexey88 Jan 17, 2024
@planv planv linked a pull request Jan 18, 2024 that will close this issue
@planv
Copy link
Contributor

planv commented Jan 22, 2024

Hello @ravimallya

It was solved in version 3.4.0.
Please let us know how it works for you.

@planv
Copy link
Contributor

planv commented Jan 29, 2024

As we have not yet received a response from you in the past 7 days, we will be closing the current issue.
If you have any questions, please feel free to re-open it.

@planv planv closed this as completed Jan 29, 2024
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

Successfully merging a pull request may close this issue.

3 participants