Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

AUTO_INCREMENT portability fix (#750)

AUTO_INCREMENT isn't portable SQL.  dbforge converts it to different types
in different databases, and they don't all work the same.

Inserting 0 or NULL into an AUTO_INCREMENT column is MySQL-specific.
It doesn't work in PostgreSQL.  Use the obvious portable approach of not
assigning a value to the AUTO_INCREMENT column.

It seems this approach obvious to most other people as well :).
This only affected one migration mentioned in issue #750,
and the creation of new roles.

There was similar-looking code in users and builder which shouldn't affect
anything, but I've tidied it away so we can be sure.
  • Loading branch information...
commit 70306fe54afc705059407c58014c82d6aa034c54 1 parent b2a9636
@sourcejedi sourcejedi authored
View
13 bonfire/migrations/003_Permission_system_upgrade.php
@@ -76,12 +76,17 @@ public function up()
{
if($field != 'role_id' && $field != 'permission_id')
{
- $this->db->query("INSERT INTO {$prefix}permissions VALUES (0,'{$field}','','active');");
+ $this->db->insert('permissions', array('name' => $field));
}
}
- $this->db->query("INSERT INTO {$prefix}permissions VALUES (0,'Permissions.Settings.View','Allow access to view the Permissions menu unders Settings Context','active');");
- $this->db->query("INSERT INTO {$prefix}permissions VALUES (0,'Permissions.Settings.Manage','Allow access to manage the Permissions in the system','active');");
-
+ $this->db->insert('permissions', array(
+ 'name' => 'Permissions.Settings.View',
+ 'description' => 'Allow access to view the Permissions menu unders Settings Context'
+ ));
+ $this->db->insert('permissions', array(
+ 'name' => 'Permissions.Settings.Manage',
+ 'description' => 'Allow access to manage the Permissions in the system',
+ ));
// create the new bf_role_permissions table
$this->dbforge->add_field("role_id int(11) NOT NULL");
View
4 bonfire/modules/builder/views/files/controller.php
@@ -277,10 +277,6 @@ public function edit()
*/
private function save_{$module_name_lower}(\$type='insert', \$id=0)
{
- if (\$type == 'update') {
- \$_POST['{$primary_key_field}'] = \$id;
- }
-
{validation_rules}
if (\$this->form_validation->run() === FALSE)
View
2  bonfire/modules/roles/controllers/settings.php
@@ -297,8 +297,6 @@ private function save_role($type='insert', $id=0)
$this->form_validation->set_rules('default', 'lang:role_default_role', 'trim|is_numeric|max_length[1]');
$this->form_validation->set_rules('can_delete', 'lang:role_can_delete_role', 'trim|is_numeric|max_length[1]');
- $_POST['role_id'] = $id;
-
if ($this->form_validation->run() === FALSE)
{
return FALSE;
View
1  bonfire/modules/users/controllers/settings.php
@@ -497,7 +497,6 @@ private function save_user($type='insert', $id=0, $meta_fields=array(), $cur_rol
}
else
{
- $_POST['id'] = $id;
$this->form_validation->set_rules('email', lang('bf_email'), 'required|trim|unique[users.email,users.id]|valid_email|max_length[120]');
$this->form_validation->set_rules('password', lang('bf_password'), 'min_length[8]|max_length[120]|valid_password|matches[pass_confirm]');
$this->form_validation->set_rules('pass_confirm', lang('bf_password_confirm'), '');

0 comments on commit 70306fe

Please sign in to comment.
Something went wrong with that request. Please try again.