As discussed.

All config entities are re-saved on config sync and entity query needs to load them all into memory and filtering is done in PHP.

Possibly only install them explicitly on-demand and just keep the files around as a default and to be able to list them on an Add form.

It's fairly easy to just create a FileStorage and point it to a directoy and make it load config from there (just config, not entities).

We do that to load optional config entities that depend on other modules: https://github.com/karanpoddar/monitoring/blob/gsoc-plugin/monitoring.mo...

Comments

xano’s picture

What about adding an Import currency local action next to Add new currency, and provide a selection form that lists all currencies. The user picks one, and the currency is immediately imported. The user can then either be redirected to the entity list, or to the edit form of the imported currency to make some possible final changes.

I haven't looked into this yet, but do you know how easy it is to import config into a full entity object? Is the config entity import code reusable enough?

berdir’s picture

The code I referenced does import config entities. So yes, something like that could work, or you could somehow combine it into a single form, similar to how language does it at admin/config/regional/language/add

You can chose between an existing ready-to-import currency or select "Custom currency".

xano’s picture

I don't think the way admin/config/regional/language/add does it is good UX. You have to read the help text to understand that adding a custom currency requires you to select the last option from the list. I'd like the Currency UI to communicate the two possible actions more clearly than this.

I hadn't followed the link yet. Thank you. It's exactly what we need.

xano’s picture

Status: Active » Needs review
Issue tags: +Needs tests
StatusFileSize
new86.58 KB

The config import example code you linked to was very useful. Thanks!

This patch has a working solution (without test coverage as I approached this from the UI side first). It feels unambiguous, except maybe for the fact that we have two local actions and newcomers may not understand the difference straight away.

xano’s picture

If we use this solution, we will also need to remove currency_install().

Status: Needs review » Needs work

The last submitted patch, 4: currency_2304635_4.patch, failed testing.

xano’s picture

The tests fail (mostly) because they expect currencies to be imported by default.

xano’s picture

StatusFileSize
new202.66 KB

This patch does the same thing for currency locales, as there are a couple hundred of them as well. It also moved the import code to a dedicated service. It still needs test coverage.

Xano queued 4: currency_2304635_4.patch for re-testing.

The last submitted patch, 4: currency_2304635_4.patch, failed testing.

xano’s picture

Status: Needs work » Needs review

I'm considering moving all currency metadata back to bartfeenstra/currency again after this, so the data can be maintained separately. This was done for Currency 7.x-2.x and the only reason this wasn't done for 8.x-3.x, is that I wanted default config to be imported on install.

Status: Needs review » Needs work

The last submitted patch, 8: currency_2304635_8.patch, failed testing.

berdir’s picture

Priority: Normal » Major

Haven' tested yet, but setting to major as I think this is pretty important. My config export folder exploded with adding currency, makes it harder to work with that. And also slower, but didn't profile/benchmark this (yet)

Status: Needs work » Needs review

Xano queued 8: currency_2304635_8.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 8: currency_2304635_8.patch, failed testing.

berdir’s picture

Finally have some numbers. On a somewhat slow, virtual system, installing currency took 2.4 minutes.

Most other modules take 4-5 seconds on the same system (comparing timings of batch requests in the installer).

So yes, we need this. Should also speed up web tests nicely ;)

Status: Needs work » Needs review

Xano queued 8: currency_2304635_8.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 8: currency_2304635_8.patch, failed testing.

xano’s picture

StatusFileSize
new4.06 KB
new202.79 KB
xano’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: currency_2304635_19.patch, failed testing.

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new211.48 KB
new206.59 KB

- Added test coverage for the new code.
- Moved all default config to the same directory. This allows the code to be much simpler.
- The XXX currency is now imported upon installation, because it is the non-removable default currency.
- Shorthand array syntax.

Status: Needs review » Needs work

The last submitted patch, 22: currency_2304635_22.patch, failed testing.

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new6.21 KB
new576.69 KB
xano’s picture

StatusFileSize
new211.49 KB

And now including file moves instead of deletions.

The last submitted patch, 24: currency_2304635_24.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 25: currency_2304635_24.patch, failed testing.

xano’s picture

Status: Needs work » Needs review
StatusFileSize
new5.33 KB
new216.82 KB
berdir’s picture

Yes, as expected, currency install went down to the usual 4-5seconds on the system that I tested. Which is a virtual service with pretty slow IO. The difference is a lot smaller on my laptop with SSD.

Didn't do a code review, but +1 in general on the performance aspect.

xano’s picture

Status: Needs review » Fixed

Thanks!

  • Xano committed 9a12720 on
    Issue #2304635 by Xano, Berdir: Fixed Installing all currencies as...
xano’s picture

Status: Fixed » Needs review
StatusFileSize
new2.9 KB

Let's fail gracefully (and in accordance with the interface) when importing the same entities twice.

  • Xano committed 2b1476f on 8.x-3.x
    Issue #2304635 by Xano: Fixed Installing all currencies as default...
xano’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nnevill’s picture

StatusFileSize
new1.03 KB

Issue has been closed 7 years ago :)

But I still have what to add here. I've attached small patch which allow easily import all currencies after module installation. I don't think it makes sense to import them during module installation because probably you don't need all of them. But the ability to import several currencies at once makes much sense for me.

So to import currencies go to /admin/config/regional/currency, click "Import a currency", select currencies you have to import and click "Import".

Hope this small patch will be useful for someone else.