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

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

Open
2 tasks done
jackkemmish opened this issue May 17, 2024 · 1 comment
Open
2 tasks done

Comments

@jackkemmish
Copy link

jackkemmish commented May 17, 2024

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

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

PR

@wernerkrauss
Copy link

Is this issue now fixed with the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants