6.0.0-beta1
▾
Tasks
New Task
Search
Photos
Wiki
▾
Tickets
New Ticket
Search
dev.horde.org
Toggle Alerts Log
Help
11/7/25
H
istory
A
ttachments
C
omment
W
atch
Download
Comment on [#8225] Rdo Mapper update function cannot create new records from Horde_Rdo_Base objects
*
Your Email Address
*
Spam protection
Enter the letters below:
__ .__ . . ..__. / `[__)| |__|[__] \__.| |___| || |
Comment
> PROBLEM > > > > The Horde_Rdo_Mapper::update tries to create new records from > Horde_Rdo_Base objects, assigning a null value for the primary key. > > > > Example: > > > > class MyTable extends Horde_Rdo_Base ... > > > > $row = new MyTable(array(some values here)); > > $row->save(); // calls the mapper update function > > > > Fatal error: Uncaught exception 'Horde_Rdo_Exception' with message > 'Column 'mytable_id' cannot be null... > > > > This is happening with a fairly default Apache/PHP installation on a > MacBook using MySQL. > > > > PATCH > > > > Suggest modifying the Horde_Rdo_Mapper::update function to unset the > primary key before calling create on the array. The key has already > been proven empty by the if statement, so I can't imagine any > negative effect here. > > > > public function update($object, $fields = null) > > { > > if ($object instanceof Horde_Rdo_Base) { > > $key = $this->model->key; > > $id = $object->$key; > > $fields = iterator_to_array($object); > > > > if (!$id) { > > // Object doesn't exist yet; create it instead. > > unset($fields[$key]); > > $object = $this->create($fields); > > return 1; > > } > > > > SIDENOTE > > > > The CVS repository for Rdo seems to be missing or just not showing files: > > > > http://cvs.horde.org/framework/Rdo/Rdo/ > > > > Also,
Attachment
Watch this ticket
N
ew Ticket
M
y Tickets
S
earch
Q
uery Builder
R
eports
Saved Queries
Open Bugs
Bugs waiting for Feedback
Open Bugs in Releases
Open Enhancements
Enhancements waiting for Feedback
Bugs with Patches
Enhancements with Patches
Release Showstoppers
Stalled Tickets
New Tickets
Horde 5 Showstoppers