Skip to content

Document singleton pattern changes in customfields handler. - #1661

Open
paulholden wants to merge 1 commit into
moodle:mainfrom
paulholden:customfields-singleton
Open

Document singleton pattern changes in customfields handler.#1661
paulholden wants to merge 1 commit into
moodle:mainfrom
paulholden:customfields-singleton

Conversation

@paulholden

@paulholden paulholden commented Jul 29, 2026

Copy link
Copy Markdown
Member

See MDL-88176.

Copilot AI review requested due to automatic review settings July 29, 2026 07:21
@netlify

netlify Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploy Preview for moodledevdocs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c9060c6
🔍 Latest deploy log https://app.netlify.com/projects/moodledevdocs/deploys/6a69aa097bd59c000af788a0
😎 Deploy Preview https://deploy-preview-1661--moodledevdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents the change in Moodle 5.2 that moves \core_customfield\handler::create(...) static caching/reset behavior into the base handler, and updates the Custom fields API docs accordingly.

Changes:

  • Added a Moodle 5.2 developer update entry describing the base handler create() caching/reset change (MDL-88176).
  • Updated Custom fields API documentation (current + 5.2) to reflect the base handler’s create() behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
versioned_docs/version-5.2/devupdate.md Adds a 5.2 dev update note about the base customfields handler create() caching/reset change.
versioned_docs/version-5.2/apis/core/customfields/index.md Updates the 5.2 Custom fields API docs to describe the base handler create() behavior.
docs/apis/core/customfields/index.md Updates the current Custom fields API docs to describe the base handler create() behavior.

Comment on lines +42 to +43
The base `\core_customfield\handler::create(...)` method now implements static caching/reset itself, so all implementation of the same from extending
classes should be removed.
Component/plugin that uses custom fields must define a **handler class** for each area and a **configuration page**. Handler class must be called `<PLUGINNAME>/customfield/<AREA>_handler` and be placed in autoloaded location `<PLUGINDIR>/classes/customfield/<AREA>_handler.php`. This class must extend **\core_customfield\handler** . Configuration page may be located anywhere. For course custom fields configuration the admin settings page is used [/course/customfield.php](https://github.com/moodle/moodle/blob/main/course/customfield.php). If the area uses `itemid` this page should take `itemid` as a parameter.

Handler has protected constructor, to get a handler call `create()` method. Some areas may choose to return a singleton here:
Handler has protected constructor, to get a handler call `create()` method. The base class implementation returns a singleton here:
Component/plugin that uses custom fields must define a **handler class** for each area and a **configuration page**. Handler class must be called `<PLUGINNAME>/customfield/<AREA>_handler` and be placed in autoloaded location `<PLUGINDIR>/classes/customfield/<AREA>_handler.php`. This class must extend **\core_customfield\handler** . Configuration page may be located anywhere. For course custom fields configuration the admin settings page is used [/course/customfield.php](https://github.com/moodle/moodle/blob/main/course/customfield.php). If the area uses `itemid` this page should take `itemid` as a parameter.

Handler has protected constructor, to get a handler call `create()` method. Some areas may choose to return a singleton here:
Handler has protected constructor, to get a handler call `create()` method. The base class implementation returns a singleton here:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants