silverstripe / silverstripe-restfulserver

RestfulServer module for Silverstripe CMS
http://www.silverstripe.org/restfulserver-module/
BSD 3-Clause "New" or "Revised" License
46 stars 48 forks source link

Calling mb_check_encoding() without argument is deprecated PHP 8.2 #123

Open jackkemmish opened 6 months ago

jackkemmish commented 6 months ago

Module version(s) affected

v3.0

Description

Hi there,

I am using this module on a fresh install of Silverstripe, and am running into an issue trying to access the api for the Page type.

The error is:

[Deprecated] mb_check_encoding(): Calling mb_check_encoding() without argument is deprecated
GET /api/v1/Page

How to reproduce

I am trying the simple integration here on the Page type, which causes the above error when trying to go to http://my-cool-site.local/api/v1/Page.

<?php

namespace {

    use SilverStripe\CMS\Model\SiteTree;

    class Page extends SiteTree
    {
        private static $db = [];

        private static $has_one = [];

        private static $api_access = true;

        private static $searchable_fields = [
            'Title',
            'URLSegment',
            'ParentID'
        ];

        public function canView($member = null)
        {
            return true;
        }
    }
}

I have tried it by specifying the values for $api_access and this does work e.g.

<?php

namespace {

    use SilverStripe\CMS\Model\SiteTree;

    class Page extends SiteTree
    {
        private static $db = [];

        private static $has_one = [];

        private static $api_access = [
            'view' => [
                'ClassName',
                'Title',
                'MenuTitle',
                'URLSegment',
                'ParentID',
                'ShowInMenus'
            ]
        ];

        private static $searchable_fields = [
            'Title',
            'URLSegment',
            'ParentID'
        ];

        public function canView($member = null)
        {
            return true;
        }
    }
}

Any idea why I can't expose all the fields and have to specify them exactly?

I'm trying to expose them all so I can debug as to why my has_one relationships aren't appearing, as I have done the below to get an image added to the api results but it's not appearing in the results:

    private static $has_one = [
        'ListImage' => Image::class
    ];

    private static $api_access = [
            'view' => [
                ...otherValues,
                'ListImageID'
            ]
        ];

Thanks in advance!

Jack

Possible Solution

No response

Additional Context

No response

Validations

PR