nextcloud / nextcloud/notify_push

`Error: php_literal_parser::unexpected_token`

Open
#323 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
344
Forks
64
Avg merge
2d 10h
Merged PRs (30d)
5

Description

⚠️ This issue respects the following points: ⚠️
  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.
Bug description

I am trying to configure the user profile fields' default visibility, and according to the docs, it should be possible within config.php: https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/profile_configuration.html#property-scopes
So I tried that like so:

<?php
$CONFIG = array (
  // other irrelevant config
  'account_manager.default_property_scope' => 
  array (
    \OCP\Accounts\IAccountManager::PROPERTY_DISPLAYNAME => \OCP\Accounts\IAccountManager::SCOPE_LOCAL,
    \OCP\Accounts\IAccountManager::PROPERTY_EMAIL => \OCP\Accounts\IAccountManager::SCOPE_LOCAL,
    \OCP\Accounts\IAccountManager::PROPERTY_AVATAR => \OCP\Accounts\IAccountManager::SCOPE_LOCAL,
  ),
  'maintenance' => false,
);

Which, however, as I sort of expected, resulted in this error when starting Nextcloud:

Error: php_literal_parser::unexpected_token
  × Error while parsing nextcloud config.php
  ╰─▶ Error while parsing '/var/www/html/config/config.php':
      No valid token found, expected one of boolean literal, integer literal,
      float literal, string literal, 'null', ')', 'array' or '['
     ╭─[102:1]
 102 │   array (
 103 │     \OCP\Accounts\IAccountManager::PROPERTY_DISPLAYNAME => \OCP\Accounts\IAccountManager::SCOPE_LOCAL,
     ·     ┬
     ·     ╰── Expected boolean literal, integer literal, float literal, string literal, 'null', ')', 'array' or '['
 104 │     \OCP\Accounts\IAccountManager::PROPERTY_EMAIL => \OCP\Accounts\IAccountManager::SCOPE_LOCAL,
     ╰────

So I went ahead, and changed these values to strings, like so:

<?php
$CONFIG = array (
  // other irrelevant config
  'account_manager.default_property_scope' => 
  array (
    '\OCP\Accounts\IAccountManager::PROPERTY_DISPLAYNAME' => '\OCP\Accounts\IAccountManager::SCOPE_LOCAL',
    '\OCP\Accounts\IAccountManager::PROPERTY_EMAIL' => '\OCP\Accounts\IAccountManager::SCOPE_LOCAL',
    '\OCP\Accounts\IAccountManager::PROPERTY_AVATAR' => '\OCP\Accounts\IAccountManager::SCOPE_LOCAL',
  ),
  'maintenance' => false,
);

Didn't work. No errors this time, but creating a new user, the display name, email and avatar are still set to "Federated".
So I tried escaping the backslashes:

<?php
$CONFIG = array (
  // other irrelevant config
  'account_manager.default_property_scope' => 
  array (
    '\\OCP\\Accounts\\IAccountManager::PROPERTY_DISPLAYNAME' => '\\OCP\\Accounts\\IAccountManager::SCOPE_LOCAL',
    '\\OCP\\Accounts\\IAccountManager::PROPERTY_EMAIL' => '\\OCP\\Accounts\\IAccountManager::SCOPE_LOCAL',
    '\\OCP\\Accounts\\IAccountManager::PROPERTY_AVATAR' => '\\OCP\\Accounts\\IAccountManager::SCOPE_LOCAL',
  ),
  'maintenance' => false,
);

Nope. Same as when not escaping them.

Steps to reproduce
  1. Change default visibility of profile fields, as it is provided in the docs, or even in the code itself
  2. Watch errors in the log
Expected behavior

New users should be created with the configured profile fields visibility

Installation method

Official All-in-One appliance

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.0

Web server

Apache (supported)

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?
  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other
Configuration report
{
    "system": {
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "password": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "overwritehost": "<removed manually>",
        "overwriteprotocol": "https",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "localhost",
            "<removed manually>"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "pgsql",
        "version": "24.0.6.1",
        "overwrite.cli.url": "<removed manually>",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "loglevel": "2",
        "log_type": "file",
        "logfile": "\/var\/www\/html\/data\/nextcloud.log",
        "log_rotate_size": "10485760",
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "preview_max_x": "2048",
        "preview_max_y": "2048",
        "jpeg_quality": "60",
        "enabledPreviewProviders": {
            "1": "OC\\Preview\\Image",
            "2": "OC\\Preview\\MarkDown",
            "3": "OC\\Preview\\MP3",
            "4": "OC\\Preview\\TXT",
            "5": "OC\\Preview\\OpenDocument",
            "6": "OC\\Preview\\Movie"
        },
        "enable_previews": true,
        "upgrade.disable-web": true,
        "mail_smtpmode": "smtp",
        "trashbin_retention_obligation": "auto, 30",
        "versions_retention_obligation": "auto, 30",
        "activity_expire_days": "30",
        "simpleSignUpLink.shown": false,
        "share_folder": "\/Shared",
        "tempdirectory": "\/mnt\/ncdata\/tmp\/",
        "one-click-instance": true,
        "one-click-instance.user-limit": 100,
        "htaccess.RewriteBase": "\/",
        "files_external_allow_create_new_local": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "SK",
        "mail_smtpsecure": "ssl",
        "mail_sendmailmode": "smtp",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauth": 1,
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "default_language": "sk",
        "default_locale": "sk",
        "account_manager.default_property_scope": {
            "displayname": "v2-local",
            "email": "v2-local",
            "avatar": "v2-local"
        },
        "maintenance": false
    }
}
List of activated Apps
Enabled:
  - accessibility: 1.10.0
  - activity: 2.16.0
  - admin_audit: 1.14.0
  - apporder: 0.15.0
  - calendar: 3.5.1
  - circles: 24.0.1
  - cloud_federation_api: 1.7.0
  - comments: 1.14.0
  - contacts: 4.2.2
  - contactsinteraction: 1.5.0
  - dashboard: 7.4.0
  - dav: 1.22.0
  - deck: 1.7.1
  - federatedfilesharing: 1.14.0
  - federation: 1.14.0
  - files: 1.19.0
  - files_pdfviewer: 2.5.0
  - files_rightclick: 1.3.0
  - files_sharing: 1.16.2
  - files_trashbin: 1.14.0
  - files_versions: 1.17.0
  - files_videoplayer: 1.13.0
  - firstrunwizard: 2.13.0
  - logreader: 2.9.0
  - lookup_server_connector: 1.12.0
  - nextcloud-aio: 0.2.0
  - nextcloud_announcements: 1.13.0
  - notifications: 2.12.1
  - notify_push: 0.5.0
  - oauth2: 1.12.0
  - password_policy: 1.14.0
  - photos: 1.6.0
  - privacy: 1.8.0
  - provisioning_api: 1.14.0
  - recommendations: 1.3.0
  - serverinfo: 1.14.0
  - settings: 1.6.0
  - sharebymail: 1.14.0
  - support: 1.7.0
  - survey_client: 1.12.0
  - systemtags: 1.14.0
  - tasks: 0.14.5
  - text: 3.5.1
  - theming: 1.15.0
  - twofactor_backupcodes: 1.13.0
  - twofactor_totp: 6.4.1
  - viewer: 1.8.0
  - weather_status: 1.4.0
  - workflowengine: 2.6.0
Disabled:
  - encryption
  - files_external
  - user_ldap
  - user_status: 1.4.0
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
Nothing even remotely relevant in the log. Just a failed login and errors from weeks ago.
Additional info

@tcitworld implemented this, so perhaps he can elaborate? I looked at your code, but I only have very basic knowledge of PHP, so unfortunately I cannot pin down what should be changed to make this work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the profile-configuration documentation and config/config.sample.php around line 2181, then compare the documented values with the php_literal_parser error in config.php. Determine whether the example or the configuration parsing behavior is incorrect, and verify the configured visibility by creating a new user on a fresh installation.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.