PageNameFormula is an extension that provides a page_name_formula that will rename a page based on a formula if any template field within the formula has changed.
The idea comes from Yaron Koren during EMWCon Spring 2017 as a project for the Create Camp day.
I (Mark Hershberger) decided to use the extension as an example for how to build an extension.
Supppose you have a page with the name Main_Page and it includes {{#page_name_formula:{{Main_Page_Name}}}} in the wikitext of the page.
The first time you save,
- the result of the {{Main_Page_Name}} template would be checked,
- the current name (Main_Page) and revision number is stored in the page_name_mapping database table, and
- if the template resulted in anything but Main_Page, then the page is added to the job queue to be renamed.
When a page renaming job is found in the job queue,
- the page is renamed using the MovePage class,
- the new name (Main_Page) and revision number is stored in the page_name_mapping database table, and
- unless otherwise specified, a redirect is left in place, and
- any double redirects are fixed, unless [https://www.mediawiki.org/wiki/Manual:$wgFixDoubleRedirects $wgFixDoubleRedirects] is false.