Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Guillaume Weyland

Make segment available to all users: missing option on file storage read-only

Hello,

I’m contacting you about an issue concerning the Save segment (saved filters).
In particular, the option “Make available for all users” checkbox is missing.

From our tests, here’s how to reproduce:
– AC pro 6.4.20 + WP 6.7.1
– hooks enabled:
add_filter(‘acp/storage/file/directory’, fn () => ‘etc/admin-columns’);
add_filter(‘acp/storage/file/directory/writable’, ‘__return_false’);

For a given CPT (let’s say the default article):
– have a saved PHP file configuration
– add a new custom view to the table (which will be saved in DB)

Result:
“Make available for all users” option is:
– NOT available on the default view (PHP file one)
– AVAILABLE on the additional view (DB stored one)

Documentation says :

When moving to a live-environment, you probably want your local file settings to be loaded as read-only and make the database the default storage engine again. The following hook allows you to easily switch between read-only storage or writable storage.

But I’m wondering if there’s an issue when:
– Base view are stored in PHP
– Segments are stored in DB

The strange thing is, the user can still save a segment for himself, and those are saved in the DB. But the checkbox to make it available for all users is not shown.

I checked and my user has the “manage_admin_columns” permission.
If I go back to my test case, If I export the additional view (where the checkbox is shown), and add it to PHP file as default view: the checkbox is NOT available.

I tried to debug the JS side around ac-modal-create-segment by adding a checkbox and manually logging some objects. But as JS is minified and seems some svelte obfuscated, I’m not able to find what the condition checked to display the checkbox.

Thank you for your help.

1 week, 2 days ago
Guillaume Weyland

Note that we were on 6.2.x version, and updated to 6.4.20. The issue may have been introduced in 6.3 from your changelogs.

I also tried to convert PHP config file to 6.4.20 format, but the results are the same.

Thanks

1 week, 2 days ago
Stefan van den Dungen Gronovius
Developer

Thanks for your message and feedback.

Technically, global segments are considered part of a list screen (view). When you make a view read-only using local storage, segments are also stored in PHP and not in the database.
As a result, when a view with local storage is in read-only mode, creating global saved filters is also disabled — it effectively goes into read-only mode as well.

We introduced this behavior in version 6.3, and it’s working as intended.
At this time, we don’t have any plans to change it, but I completely understand the reasoning behind your feedback and will make sure it’s noted internally.

1 week, 1 day ago
Guillaume Weyland

Hello Stefan,

Thank you for your answer.
I understand your logic, and it matches my test results and code analysis.

To me, it’s kind of a regression :
– File storage is very useful for development and deployment
– FS read-only mode is kind of needed as project is under GIT and we deploy multiple instances
– database storage for segment is perfect for production, as each instance have its own DB, but the same GITed codebase

Making some tests, it seems that global segment in DB works perfectly for the default view in PHP files.

If I:
– Edit my segment in DB to make it on the default view ID
– set the “global” column to 1
– edit Segment controller read_action() to add something like this:

$user_segments = array_merge(
iterator_to_array($user_segments, false),
iterator_to_array($global_segments, false)
);

I have my global segment available and working on my default vue.

So in theory, I could use the acp/search/segments filter to push some global filters.

The only issue is that I cannot save global filters. Even adding the checkbox manually, it’s not added to the save segment payload.

So strange thing to me is that everything seems to work.

Thank you

1 week ago
Guillaume Weyland

This was my complete code edition in Segment controller:

$global_segments = $this->segment_repository->find_all_shared(
            $list_screen->get_id()
        );
        $user_segments = array_merge(
            iterator_to_array($user_segments, false),
            iterator_to_array($global_segments, false)
        );
1 week ago

You must be logged in to reply to this topic.