Preserve Advanced Extension Settings in FreePBX GQL API #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
[bug]: Advanced Settings Reset or Omitted During Extension Creation/Modification via GQL API
Original Issue: FreePBX/issue-tracker#528
FreePBX Version: 17.0.19.16
Asterisk Version: 21.4.3
Problem
When creating or modifying extensions via the FreePBX GQL API, advanced settings are often reset to default values or omitted entirely. This issue stems from the GQL API’s method of updating extensions: extensions are deleted and recreated without fully retaining user-specified parameters. Consequently, essential settings (e.g., DTMF Signaling, Transport, Call Waiting, Ring Time) revert to defaults, disrupting configurations that rely on specific, user-defined values.
Solution
To resolve this issue, I enhanced the API’s handling of extension updates by merging all relevant data sources into a unified dataset before calling the update function. This modification ensures that all user-defined advanced settings are retained unless explicitly undefined, aligning the API’s behavior with expected user outcomes.
Changes Made
Modifications in Extensions.php
$total
to combine data from$extensionsExists
,$users
, and$input
. This unified dataset includes the full scope of parameters needed to persist all advanced settings during updates.processQuickCreate()
to utilize$total
instead of$input
, ensuring complete parameter retention.Enhancements in Core.class.php
generateDefaultUserSettings()
to ensure that$settings
correctly reflects user-defined values:Expanded Field Set in
getMutationFieldsupdate()
getMutationFieldsupdate()
to incorporate additional parameters where necessary. This ensures that essential fields are correctly recognized and updated during API calls. For example:Additions to Default Parameters in
generateDefaultUserSettings()
generateDefaultUserSettings()
to include new parameters, such asdialopts
,call_screen
, andrvolume
, to ensure these fields can be managed and modified via the API. Code added:Thank you for reviewing this merge request. Please let me know if further clarification or adjustments are required.