Because of the order by flags statements in /var/www/html/admin/modules/core/inc.functions.php (and possibly others)
the entries in the conf files are not written in an appropriate order for all scenarios.
This is most apparent when using either custom trunks (or my earlier patch for adding OOH323, MGCP & Skinny support) and the protocol in question uses line statements (which depend on context) where context appears after the line definitions and is therefore those extensions/trunks try to use the "Default" context. This would also cause problems on multiline endpoints where different parameters applied to different lines.
This would also be a serious issue for any context sensitive value on a trunk which did not appear after context= when reverse alpha sorted
The order values are entered into the FreePBX GUI therefore needs to be preserved
An example of a skinny_additional.conf generated by FreePBX would be
[1004]
version=P03-08-02
secret=1004
record_out=Adhoc
record_in=Adhoc
pickupgroup=
model=7985
mailbox=1004@device
linelabel1=1004
linelabel2=Helpdesk
line=1
line=2
host=192.168.1.253
disallow=all
dial=Skinny/1@1004
device=SEP000F6644F5A6
context=from-internal
context=from-internal
callgroup=
callerid=device <1004>
callerid=Helpdesk
allow=ulaw
accountcode=
When what was actually desired and entered in the GUI was
[1004]
version=P03-08-02
secret=1004
record_out=Adhoc
record_in=Adhoc
model=7985
host=192.168.1.253
disallow=all
device=SEP000F6644F5A6
context=from-internal
line=1
linelabel1=1004
callerid=device <1004>
dial=Skinny/1@1004
pickupgroup=
callgroup=
callerid=device <1004>
allow=ulaw
accountcode=
mailbox=1004@device
context=from-helpdesk
line=2
linelabel2=Helpdesk
dial=Skinny/2@1004
pickupgroup=
callerid=Helpdesk
allow=ulaw
accountcode=
mailbox=1004@device
Disregarding the multi-line issues an issue still remains where context is defined before context sensitive values