darrenjacoby / intervention

WordPress plugin to configure wp-admin and application state using a single config file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Something goes wrong setting options / saving to database

huubl opened this issue · comments

commented

Hi,

Something goes wrong when using this settings:

<?php
use function Env\env;

return [
    'application' => [
        'general' => [
            'site-title' => 'My website',
            'wp-address' => env('WP_SITEURL'),
            'site-address' => env('WP_HOME'),
            'admin-email' => 'my@email.com',
            'admin-email.verification' => false,
            'email-from' => 'info@mysite.nl',
            'email-from-name' => 'My website',
            'membership' => false,
            'default-role' => 'subscriber',
            'language' => 'nl_NL',
            'timezone' => 'Europe/Amsterdam',
            'date-format' => 'j F Y',
            'time-format' => 'H:i',
            'week-starts' => 'Mon',
        ],
        'writing' => [
            'emoji' => false,
            'default-category' => 1,
            'default-post-format' => 'standard',
            'post-via-email.server' => 'mail.example.com',
            'post-via-email.port' => 110,
            'post-via-email.login' => 'login@example.com',
            'post-via-email.pass' => 'password',
            'post-via-email.default-category' => 1,
            'update-services' => 'http://rpc.pingomatic.com/',
        ],
        'reading' => [
            'front-page' => 2,
            'front-page.posts' => 454,
            'posts-per-page' => 9,
            'posts-per-rss' => 9,
            'rss-excerpt' => 'summary',
        ],
        'media' => [
            'sizes.thumbnail' => [
                'width' => 300,
                'height' => 200,
                'crop' => true,
            ],
            'sizes.medium' => [
                'width' => 640,
                'height' => 480,
            ],
            'sizes.large' => [
                'width' => 1100,
                'height' => 800,
            ],
            'uploads.organize' => true,
        ],
        'permalinks' => [
            'structure' => '/nieuws/%year%/%monthnum%/%day%/%postname%/',
            'category-base' => 'nieuws/categorie',
            'tag-base' => 'nieuws/tag',
        ],
        'privacy.policy-page' => 2731,
    ],
];

When I check the database values, they are not changing or (when I click save on the admin general settings page ) wrong. For example the media options get:

option_name option_value autoload
thumbnail_size_w 0 no
thumbnail_size_h 0 no
thumbnail_crop 1 no
medium_size_w 0 no
medium_size_h 0 no

When saving the (partly) locked setting on the admin general settings page (by the save button ) and then comment out the application -> general settings I get this:

image

Am I doing something wrong?

  • Using Intervention dev-master branch (loaded as mu-plugin)
  • Bedrock / Sage 10

Hey @huubl,

I’m on my phone now, but the new versions use pre_option which is faster than updating the db, so it wouldn’t reflect in the db itself. I am working on providing a sync option to update the db, should be releasing that soon.

Hey @huubl,

Just tested with a new copy from dev-master here and no problems with the above config.

EDIT: just re-read your comment, and that behaviour sounds correct. Intervention does not update the DB by using application (it did in previous versions). There will be an option for this soon. Without application being set, or intervention being active, it will revert to the previous db settings.

#64 for reference.

image

@huubl ,

Interesting, I was finally able to replicate. The problem is that Intervention is setting fields in application as disabled on the option pages, and so when you save settings from WP, the disabled field values aren't pulling through on save and instead clearing the DB entries. Not ideal. I think changing from disabled to readonly will solve the issue, but still testing.

Really appreciate you picking this up, got a hotfix up which should solve it. Let me know if it does it for you. cf57d4a

Related to the fix: the Sober\Intervention\UserInterface\Tools\Import class is missing from the repo.

@jmerilainen ah thanks! fixed.

commented

Hi @darrenjacoby,

I missed #64 Intervention using the pre_option now. I tried the current master branch with hotfix and it solves the problem.

Thanks for looking in to this!