meeting-room-booking-system / mrbs-code

MRBS application code
Other
129 stars 64 forks source link

Error when a field is removed from ADD ROOM Database #2450

Open jberanek opened 5 years ago

jberanek commented 5 years ago

Hi, I have created a new field "preparation_locker" in ADD ROOM form. Then I have edited admin.php and add.php so that it appears in the ADD ROOM FORM.

Now I want to delete this field so I followed back the way I have created this field starting with phpmy admin.

Now after this field is removed, when I try to add a new room, it shows error: database is missing.

This is the error log:

Uncaught exception 'MRBS\DBException' in /home/quickform/public_html/meetingroom/lib/MRBS/DB.php at line 109
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'preparation_blocker' cannot be null
SQL: INSERT INTO quickfor_room (room_name, sort_key, area_id, description, capacity, room_admin_email,preparation_blocker)          VALUES (?, ?, ?, ?, ?, ?, ?)
Params: Array
(
    [0] => example
    [1] => example
    [2] => 1
    [3] => Meeting Room
    [4] => 3
    [5] => example@gmail.com
    [6] => 
)

#0 /home/ron/public_html/meetingroom/mrbs_sql.inc(1843): MRBS\DB->command('INSERT INTO qui...', Array)
#1 /home/ron/public_html/meetingroom/add.php(44): MRBS\mrbsAddRoom('example', 1, '', 'Meeting Room', 3, 'example@...', NULL)
#2 {main}
MRBS GET: Array
(
)
MRBS POST: Array
(
    [csrf_token] => 45082e6b88aea6e8133fc32a44ef84e211359d40f1ed5cc8a121a7d42228b39c
    [type] => room
    [area] => 1
    [name] => example
    [description] => Meeting Room
    [capacity] => 3
    [room_admin_email] => example@gmail.com
    [room_page] => 
    [preparation_blocker] => 6
)

Reported by: *anonymous

Original Ticket: mrbs/support-requests/1748

jberanek commented 5 years ago

It looks like you probably haven't removed any of the changes you made, either to the code or to the rooms table. (By the way, when you add a custom field to the rooms table you shouldn't need to change the code. MRBS will recognise it automatically).

Original comment by: campbell-m

jberanek commented 5 years ago

No, I have removed all the changed made to add the field. Initially, I have just added a new field to room table but mrbs does not recognise it, so I have to edit the admin.php & add.php. see this support request: https://sourceforge.net/p/mrbs/support-requests/1711/

Original comment by: *anonymous

jberanek commented 5 years ago

No, I have removed all the changed made to add the field.

The preparation_blocker column must still be there in the database because otherwise you wouldn't be getting the SQL error:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'preparation_blocker' cannot be null

Similarly the code must still be there to handle the column because otherwise you would not have:

INSERT INTO quickfor_room (room_name, sort_key, area_id, description, capacity, room_admin_email,preparation_blocker)          VALUES (?, ?, ?, ?, ?, ?, ?)

and also preparation_blocker is there in your POST data.

Initially, I have just added a new field to room table but mrbs does not recognise it, so I have to edit the admin.php & add.php. see this support request

OK, I understand. MRBS will recognise it when you edit the room, but not when you first add it.

Original comment by: campbell-m