PHP error/bug



  • Hello Developers,

    Issue with lattest 2.4 b code(2.4.0.b.20170206.1427):

    when editing the dhcp leaese page The starting ID starts at is 0 (as seen in when it should be 1 for it to work correctly… 0 seams to be used for new/Add function (brings up blank page when selecting edit). To select the first row you have to select the 2nd rows edit button.

    i found a simple php error on the page:

    status_dhcp_leases.php

    with the line 249;

    or  a problem with the services_dhcp_edit.php.

    BR,
    Troy



  • That is fine. The static mapped leases array is indexed from 0.
    For a new lease it does not put any "id=".

    I tried a few combinations of adding and editing and it works for me.



  • Phil,

    Sorry about being a bit unclear on the issue.

    Yes, I understand the array should normally start at 0  ;D. But, my situation is this; I have 4 Items listed under DHCP Leases (status_dhcp_leases.php page)  id= {0,1,2,3} however, if i select edit on the first server (id 0)  a blank form opens not the MAC address associated with the first server in the list. Selecting the edit button for the 2nd server in the list opens the first server edit page. To edit the last server, I have to manually index the id to 4 in the url.

    Now, I think i may have found where the issue arises from….. on the services_dhcp.php page under the heading DHCP Static Mappings for this Interface i show five items first one being an empty/blank item with an id=0. My other 4 servers are listed under the blank/empty row with ids 1-4. So, the array for ids on this page are {0,1,2,3,4}.

    I believe the the empty/blank (id=0) was dropped from the list for the status_dhcp_leases.php page however, it seems the ids no longer correspond to the correct Items.

    To recap, In my situation I have 4 servers listed under DHCP Leases ids {0,1,2,3} {server1,server2,server3,server4}...in reality under DHCP Leases the true array is {0,1,2,3,4} {Empty,server1,server2,server3,server4}.  The first in the list is server1 however, the edit button is linked to id=0 (empty/blank) and should be linked to id=1 , Server2 has edit button linked to Id=1 etc,etc...

    As a side not the Add WOL Mapping button is correctly indexed.

    I hope this clears up the issue a bit more.

    Troy



  • I have seen that before, where the DHCP Leases list (on the Services->DHCP Server page) has got an empty entry in the first position. But I have not managed to reproduce how it can happen.

    If you delete the first entry, then I expect everything will come back into line.

    Then if you can find a way to make the blank entry appear again, please let us know how and it can be fixed.



  • Phil,

    I'm unable to delete the first entry (the delete static mapping is not saving for a blank form). It does ask if you want to delete but, wont remove the entry.

    Other things i noticed looking over the code….

    Not sure why all fields in the table are double click enabled under the DHCP Static Mappings for this Interface. Seems this should information only and/or only edited when clicking on the pencil button.

    As for correcting this condition, I would add a validation to your function for building the table and reject any nulls or W/O MAC address also when saving to the db.
    then the auto indexing should work and eliminate the possibility of "ghost" blank entry. For anyone with this issue may need to refresh the db.

    BR
    Troy



  • See Redmine Issue https://redmine.pfsense.org/issues/7233

    Can you try the code change in pull request https://github.com/pfsense/pfsense/pull/3505 ?

    That should keep the id value correctly as it skips across the "blank" entry.

    I will also look at making it possible to delete blank entries…



  • I implemented your code change from Part Fix #7233 Allow deletion of empty static map entries #3506;

    I was then able to delete the blank entry and the static dhcp list was corrected.

    however, I did not change the status_dhcp_leases.php as the newer code by rbgarga was used in the new build.

    I guess ill see if i can break it  :D



  • @DevEng:

    I implemented your code change from Part Fix #7233 Allow deletion of empty static map entries #3506;

    I was then able to delete the blank entry and the static dhcp list was corrected.

    however, I did not change the status_dhcp_leases.php as the newer code by rbgarga was used in the new build.

    I guess ill see if i can break it  :D

    Good to hear. It will be even better if you can find how to make the blank entry happen, then we can fix that also.



  • fyi with the newest update 2.4.0.b.20170208.0843 (your fixes included)…  i noticed the Blank/empty id=o returned on the services_dhcp.php page and the status_dhcp_leases page was back to the original issue.

    After deleting the blank/empty entry on the new firmware.... everything returned to the correct state, rebooted and the issue did not return.

    So, I think the issue has been corrected.... Like you Im not sure what I did to cause the problem.