Skip to content

fix PHP 8.1 deprecated warnings with str_replace in _ResourceClient _path_format #42

@Nicolas-Bouteille

Description

@Nicolas-Bouteille

PHP 8.1 has deprecated passing null as parameters to a lot of core functions such as str_replace.
in JwplatformClient.php _ResourceClient _path_format there are three calls to str_replace with potential null values as parameters.
This is the case when using _ResourceClient->list since it calls _path_format with only three parameters
$this->_path_format($this->_collection_path, $site_id, $this->_resource_name),
which means $resource_id is always null in
protected function _path_format($path, $site_id = null, $resource_name = null, $resource_id = null) {
code needs to be updated to something like:

      if ($site_id) {
        $path = str_replace("{site_id}", $site_id, $path);
      }
      if ($resource_name) {
        $path = str_replace("{resource_name}", $resource_name, $path);
      }
      if ($resource_id) {
        $path = str_replace("{resource_id}", $resource_id, $path);
      }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions