In ProcessWire 3.0.160 we’ve got some major upgrades and additions to our text-search abilities. This brings a whole new level of power to $pages->find() and similar API calls, especially when it comes to search engine type queries. More
This week we’re proud to announce the newest ProcessWire master version 3.0.164. Relative to the previous master version (3.0.148) this version adds a ton of new and useful features and fixes more than 85 issues, with more than 225 commits over a period of 7 months.
There were also a lot of technical changes in the core, including some pretty significant refactoring of several classes to further optimize and improve upon our already solid core, making it that much better. I’m confident this master version is one of our best and if you are running an older version I’d encourage you to upgrade when convenient to do so—I think you will really like what this version brings!
What’s new in ProcessWire 3.0.164
A dozen new text searching operators were added for our biggest upgrade to the Selectors system ever! This greatly expands your options for finding pages (and more) by matching text. Also included is a great new advanced text search operator that enables you to find pages by specifying words and/or phrases that must match, may match or must not match. Details + Docs
New ability to specify more than one operator in a
field=value selector. Now you can specify as many operators as you want, simply appending one to the other. This lets you essentially say “if the first operator doesn’t match, try again with the second operator”, and so on. This is best described with examples, so see the link for some really good examples of it in action: Details
Custom page classes
Now you can specify your own PHP classes for ProcessWire Page objects. This provides an even easier way to add new methods and properties to pages than hooks do, and that’s just for starters! For some, this is no doubt one of the most useful additions of ProcessWire 3.0.164 and opens a lot of new doors for site and application development in ProcessWire. Details
New “remember me” ability has been added to the two-factor authentication support in ProcessWire. This works with any of the existing Tfa modules such as TfaTotp and TfaEmail. Plus, you can configure how you want it to remember (fingerprint) users and how long it should last. Details
New auto-enable two-factor authentication support: We now have auto-enable support (forced 2FA), which lets you setup two-factor authentication for users, without their input (if they haven’t enabled it already). This is a good way to add a lot of security for very little work. This works with our TfaEmail module. Details
New versions of the TfaEmail and TfaTotp modules for ProcessWire 3.0.164. While not yet part of the core, thse modules are likely to be by the next master version. The new version of the TfaEmail module also lets you now configure what WireMail module you want it to use for sending authentication emails. If using multiple mail sending services, you’ll want your most reliable and fastest email sending service to handle these kinds of transactional emails. The TfaTotp module was upgraded to support a locally hosted QR code generator. No longer does it have to rely upon an external service to generate QR codes (previous versions used Google Charts for QR code generation). Details
Added support for logging in to the admin via your email address. To use, you must enable the "unique" flag on your "email" field (Setup > Fields > email > Advanced), and then you can enable login-by-email in the ProcessLogin module settings. If you'd like, you can support both login by username and login by email at the same time.
New $user->hasTfa() method that enables you to quickly identify if user has two-factor authentication enabled.
New $pages->has(‘selector’) API method: This method provides an optimal way to check if any page matching the given selector exists in the system. It can do this with more efficiency than
$pages->get() because it doesn’t have to load any pages. And it can do this with more efficiency than
$pages->count() because it doesn’t have to count a total number of matches. However, rather than just returning a true or false, it returns the ID of the first matching page, making it even more useful. Details
New $pages->parents() API that improves and optimizes the way that ProcessWire manages parent/child relationships between pages and increases the speed and accuracy in finding pages having a particular parent somewhere in its ancestry. Details
New $pages->getByIDs() and $pages->getID() API methods have also been added. Details
New Pages API hooks: Pages::trashReady(), Pages::deleteBranchReady(), Pages::deletedBranch(). The deleteBranch hooks cover the case of recursive deletions where an entire branch of pages is deleted. For those cases, these hooks can be more useful than the regular deleteReady() and deleted() hooks because those two are called for every single page, rather than just for the initiating page. Details
Language translation function improvements: Now you can specify multiple acceptable translations for translatable text. This is particularly handy when you want to change the default translation text, but don’t want to abandon existing translations. To use, specify bracket PHP array syntax with 2 or more phrases you'll accept translations for, rather than automatically abandoning them. This is useful in cases where you need to change the text, but do not want to automatically lose any existing translations. For example, the call:
__(['new text', 'old text']); will use a translation for 'old text' if 'new text' has not yet been translated. In the admin translation tools, it identifies these as "fallback" translations. Details
New wireLangReplacements() function that lets you programmatically change the text for any language
$this->_(‘text’) call, making it very easy to customize ProcessWire modules and/or core text that you want to change, regardless of whether you have multi-language support installed or not! Details
Files and images
Added support for predefined image size settings, enabling you to assign names to groups of image settings (in
$config->imageSizes) and then refer to those names in your
$image->size(‘name’) calls, rather than the dimensions (or other settings). This promotes greater reuse of image sizes and settings, reduces redundant code, increases the readability of your code, and makes it much simpler to accommodate changes. Details
Expanded file and image properties in the database, adding to what can be searched on file/image fields from the $pages API. This includes file size, created and modified user info, image width and height and a floating point “ratio” property, enabling you to find pages with images matching certain proportions. In addition to making these properties searchable, this change also opens the door to more easily supporting external file systems such as S3, for ProcessWire file and image assets. Details + More
Date/Time input improvements, including the addition of date select boxes (separate year, month day selects in your selected order), as well as the addition of HTML5 standard date and time inputs, with the ability to specify minimum and maximum allowed dates and times. These join our existing jQuery UI based date picker and give you a lot more options for how you want to accept input in date fields. Details
“InputfieldWrapper was updated to support customizing output on a per-field basis using the field name as an identifying factor. Previously this was only possible on per-class basis, which means that there's now a lot more flexibility built-in.” —weekly.pw #310
Upgrades to the $input->urlSegment() method: Rather than just specifying the 1-based URL segment number you want to retrieve, now you can: specify a negative number to retrieve from the end; specify a URL segment [string] you want the index for; specify the URL segment for which you want the next or previous one; specify a wildcard string to match a URL segment; and more. Details
New $input->canonicalUrl() method: When it comes to what is the canonical URL, you’ll want to consider URL segments as well as any variation of a given page (or other pages) that might be presenting the same content. URL segments, page numbers, languages and query strings (GET vars), scheme and HTTP host are all considerations, and supported by this method, enabling you to easily create accurate and quality output for your
<link rel=“canonical”> tags. Details
New find() and findOne() methods added to WireInputData class, enabling
$input->get->find('…'), etc., supporting both wildcards and regex patterns. Details
“Sanitizer got a few new methods: line(), lines(), and trunc()) and also some improvements to one of the existing methods, intArray()” … “[they are] largely the same as our existing methods, but they all come with some kind of a twist; line() (for an example) is almost identical to text(), except that max length is not enforced by default.” —weekly.pw #315
Major API improvements to Comments fields, including the ability to handle completely custom markup for comments and forms along with several new API methods. Details
Significant updates to ProcessCommentsManager including the ability to change the Page that any comment lives on, as well as the ability to change what comment another is replying to. Plus several other updates in this module.
New $config->moduleInstall setting that lets you specify what options you want to allow for module installation on the site. These can also be customized to depend on the “debug mode” state of the site. For instance, you might allow file uploads for module installation when the site is in debug mode, but not when it’s in live/production mode. Details
New API for manipulating the schema of field tables via
$fields->tableTools() which enables you to add unique indexes to fields (as one example), demonstrated with the new option to enforce unique values on email fields. Details
New Template API methods: $template->allowNewPages() returns an up or down on whether the Template accepts new pages to be created with it; $template->childTemplates() returns all Templates allowed to be used for its children; and $template->parentTemplates() returns all templates it allows for parents. Details
Upgrades to the core Debug class adding support for PHP 7 hrtime() as well as the ability to customize precision and whether you prefer millisecond or floating point second timers. In addition a new Debug::getAll() method was added and this returns all of the active debug timers. Details
“The default htaccess file was updated, and among some minor improvements there's also a new nuisance blocking/firewall section with examples and a link to the 7G Firewall by Perishable Press. (All rules in this section are disabled by default.)” —weekly.pw #315
Significant refactoring of several ProcessWire core classes: DatabaseQuery, DatabaseQuerySelect, DatabaseQuerySelectFulltext, Template, Selector, Selectors, PagesLoader, PageFinder, ProcessLogin, WireInputDataCookie and various Fieldtype classes.
Updated ProcessWire’s WireClassLoader ($classLoader API var) to support autoloading by class prefix or suffix. Details
Updated AdminThemeUikit search box to add a suggestion about typing "help" if you focus the input for a brief period without typing anything.
Thanks for reading! You can download the latest ProcessWire master version on our Downloads page. Next week, I'll be back to work on the dev branch, releasing an incremental update to ProCache, and working on a new version of FormBuilder that greatly improves the admin features and API for submitted form entries. Special thanks to ProcessWire Weekly for doing such a great job with covering the core updates every week—be sure to stop by there for the latest ProcessWire news and updates.