Jump to content

PW 3.0.198 – Core updates


ryan
 Share

Recommended Posts

ProcessWire 3.0.198 contains a mixture of new features and issue resolutions. Below are details on a few of the new features: 

Support was added for runtime page cache groups. This enables pages to be cached as a group—and just as importantly—uncached as a group. While it can be used by anybody, it was added primarily to add efficiency to $pages->findMany(), so that it can cache supporting pages (like parents and page references). Previously, it would have to load a fresh copy of each supporting page used by findMany() results (for every returned page) since findMany() used no in-memory caching. If it did cache in memory, then you could potentially run out of memory on large result sets, so that strategy was avoided. Consider the case of iterating over all pages returned by findMany() and outputting their URLs... that triggers load of all parent pages for each page in the result set. And without a memory cache, it meant it would have to do it for each page in the results. Following this week's updates, now it can cache these supporting pages for each chunk of 250 pages, offering potentially significant performance improvement in many cases, without creating excess memory usage or memory leaks. When the chunk of 250 result pages is released from memory (to make room for the next chunk), all the supporting pages (parents, page references, etc.) are also released from memory, but not before. Now findMany() can offer both memory efficiency and great performance.

For as long as I can remember, ProcessWire has had an apparently undocumented feature for dependent select fields that enables you to have two page reference fields using selects (single, multiple or AsmSelect) where the selected value in one select changes the selectable options in the other select (Ajax powered). Think of "categories" and "subcategories" selects, for example, where your selection for "categories" changes what options are selectable in "subcategories". Part of the reason it's undocumented is that it is one of those features that is a little bit fragile, and didn't work in some instances, such as within Repeater items. That changed this week, as the feature has been updated so that it can also work in Repeater items too. 

The $pages->findRaw() method was updated with a new "nulls" option (per Adrian's request in #1553). If you enable this new "nulls" option, it will add placeholders in the return value with null values for any fields you requested that were not present on each matching page. This reflects how PW's database works, in that if a field has no value, PW removes it from the database entirely. Without the nulls option (the existing behavior), it retains the more compact return values, which omit non present values completely. For example, consider the following:  

$items = $pages->findRaw("template=user, fields=email|first_name|last_name"); 

If a row in the result set had no "first_name" or "last_name" populated, then it would not appear in the that row of the return value at all...

[
  "email": "ryan@processwire.com"
]

By specifying the "nulls" option, it will still include placeholders for field values not present in the database, and these will have a value of null:

$items = $pages->findRaw("template=user, nulls=1, fields=email|first_name|last_name"); 
[
  "email": "ryan@processwire.com",
  "first_name": null,
  "last_name": null
]

By the way, if you don't specify which fields you want to get (which is the same as saying "get all") then adding the nulls option makes it provide placeholders for all fields used by the page's template. As you might expect, without the nulls option, it includes only populated fields. 

Also included in 3.0.198 are 7 issue fixes, most of which are visible in the dev branch commits log. That's all for this week. Thanks for reading this update and have a great weekend! 
 

  • Like 17
  • Thanks 1
Link to comment
Share on other sites

@ryan does Horst’s commit fix the problem of image uploads that are rotated 180 degrees when saved to a page? From what I can remember in my mini app, even the thumbnail preview when using the file upload field flips images upside down. Which isn’t a deal breaker but still. I end up doing an image rotation on the front-end so the image is showed right-side up.

Link to comment
Share on other sites

On 4/15/2022 at 10:02 PM, zoeck said:

Just have a Look at this ? 

Thank you - I think when I last tried it both selects were in a combo field (Pro module) so may not work there but might with this update - I'll check.

Link to comment
Share on other sites

  • 5 months later...

Hey @ryan is there something in the works in regards to findRaw and matrix fields?

Right now they are quite difficult to handle as I have to call each and every field that is in one or another matrix types to get my desired results.

2022-10-13_01-35.png.59197edf76cc6dbb8ecd398696f78509.png
blocks (my matrix field) - fields across some types

Something like myMatrixField.* doesn't work - unfortunatelly.
Another thing is that I can't query things like type for each of those matrix blocks.

Is there a workaround or something upcoming in those regards?

Asking for using ProcessWire as a Headless CMS with NextJS in a simple and light setup without GraphQL, RestApi modules or similar.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...