Index: kernel/classes/ezurlaliasml.php
===================================================================
--- kernel/classes/ezurlaliasml.php	(revision 22686)
+++ kernel/classes/ezurlaliasml.php	(working copy)
@@ -237,18 +237,11 @@
     */
     function store( $fieldFilters = null )
     {
-        $locked = false;
         if ( $this->ID === null )
         {
-            $locked = true;
-            $db = eZDB::instance();
-            $db->lock( "ezurlalias_ml" );
-            $query = "SELECT max( id ) + 1 AS id FROM ezurlalias_ml";
-            $rows = $db->arrayQuery( $query );
-            $id = (int)$rows[0]['id'];
-            if ( $id == 0 )
-                $id = 1;
-            $this->ID = $id;
+            $id = new eZURLAliasMlID( array() );
+            $id->store();
+            $this->ID = $id->attribute( 'id' );
         }
         if ( $this->Link === null )
         {
@@ -272,10 +265,6 @@
         }
 
         eZPersistentObject::store( $fieldFilters );
-        if ( $locked )
-        {
-            $db->unlock();
-        }
     }
 
     /*!
@@ -613,13 +602,9 @@
                 $idtmp = (int)$row['id'];
                 if ( $idtmp == $newElementID )
                 {
-                    $db->lock( "ezurlalias_ml" );
-                    $query = "SELECT max( id ) + 1 AS id FROM ezurlalias_ml";
-                    $rowstmp = $db->arrayQuery( $query );
-                    $idtmp = (int)$rowstmp[0]['id'];
-                    if ( $idtmp == 0 )
-                        $idtmp = 1;
-                    $db->unlock();
+                    $id = new eZURLAliasMlID( array() );
+                    $id->store();
+                    $idtmp = $id->attribute( 'id' );
                 }
                 $parentIDTmp = (int)$row['parent'];
                 $textMD5Tmp = eZURLALiasML::md5( $db, $row['text'] );
Index: kernel/classes/ezurlaliasmlid.php
===================================================================
--- kernel/classes/ezurlaliasmlid.php	(revision 0)
+++ kernel/classes/ezurlaliasmlid.php	(revision 0)
@@ -0,0 +1,26 @@
+<?php
+// Persistent object class auto-generated
+
+class eZURLAliasMlID extends eZPersistentObject
+{
+    function __construct( $row )
+    {
+        $this->eZPersistentObject( $row );
+    }
+
+    static function definition()
+    {
+        $def = array( "fields" => array( "id" => array( "name" => "id",
+                                                        "datatype" => "integer",
+                                                        "required" => false ) ),
+                      "keys" => array( "id" ),
+                      "function_attributes" => array(),
+                      "increment_key" => "id",
+                      "class_name" => "eZURLAliasMlID",
+                      "sort" => array(),
+                      "name" => "ezurlalias_ml_incr" );
+        return $def;
+    }
+
+}
+?>

Property changes on: kernel\classes\ezurlaliasmlid.php
___________________________________________________________________
Added: svn:eol-style
   + native

Index: kernel/sql/common/cleandata.sql
===================================================================
--- kernel/sql/common/cleandata.sql	(revision 22686)
+++ kernel/sql/common/cleandata.sql	(working copy)
@@ -23625,6 +23625,177 @@
   '10e4c3cb527fb9963258469986c16240'
 );
 
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  1
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  2
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  3
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  4
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  5
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  6
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  7
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  8
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  9
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  10
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  11
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  12
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  13
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  14
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  15
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  16
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  17
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  18
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  19
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  20
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  21
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  22
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  24
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  25
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  26
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  27
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  28
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  29
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  30
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  31
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  32
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  33
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  34
+);
+INSERT INTO ezurlalias_ml_incr (
+  id
+) VALUES (
+  35
+);
+
 INSERT INTO ezuser (
   contentobject_id,
   email,
@@ -23761,4 +23932,4 @@
   1024392098,
   14,
   'Standard'
-);
\ No newline at end of file
+);
Index: kernel/sql/mysql/kernel_schema.sql
===================================================================
--- kernel/sql/mysql/kernel_schema.sql	(revision 22686)
+++ kernel/sql/mysql/kernel_schema.sql	(working copy)
@@ -1481,6 +1481,15 @@
 
 
 
+CREATE TABLE ezurlalias_ml_incr (
+  id int(11) NOT NULL auto_increment,
+  PRIMARY KEY  (id)
+) TYPE=InnoDB;
+
+
+
+
+
 CREATE TABLE ezurlwildcard (
   destination_url longtext NOT NULL,
   id int(11) NOT NULL auto_increment,
@@ -1560,8 +1569,8 @@
   current_visit_timestamp int(11) NOT NULL default '0',
   failed_login_attempts int(11) NOT NULL default '0',
   last_visit_timestamp int(11) NOT NULL default '0',
+  login_count int(11) NOT NULL default '0',
   user_id int(11) NOT NULL default '0',
-  login_count int(11) NOT NULL default '0',
   PRIMARY KEY  (user_id),
   KEY ezuservisit_co_visit_count (current_visit_timestamp,login_count)
 ) TYPE=InnoDB;
Index: kernel/sql/postgresql/kernel_schema.sql
===================================================================
--- kernel/sql/postgresql/kernel_schema.sql	(revision 22686)
+++ kernel/sql/postgresql/kernel_schema.sql	(working copy)
@@ -919,6 +919,19 @@
 
 
 
+CREATE SEQUENCE ezurlalias_ml_incr_s
+    START 1
+    INCREMENT 1
+    MAXVALUE 9223372036854775807
+    MINVALUE 1
+    CACHE 1;
+
+
+
+
+
+
+
 CREATE SEQUENCE ezurlwildcard_s
     START 1
     INCREMENT 1
@@ -2542,6 +2555,16 @@
 
 
 
+CREATE TABLE ezurlalias_ml_incr (
+    id integer DEFAULT nextval('ezurlalias_ml_incr_s'::text) NOT NULL
+);
+
+
+
+
+
+
+
 CREATE TABLE ezurlwildcard (
     destination_url text NOT NULL,
     id integer DEFAULT nextval('ezurlwildcard_s'::text) NOT NULL,
@@ -2625,8 +2648,8 @@
     current_visit_timestamp integer DEFAULT 0 NOT NULL,
     failed_login_attempts integer DEFAULT 0 NOT NULL,
     last_visit_timestamp integer DEFAULT 0 NOT NULL,
-    user_id integer DEFAULT 0 NOT NULL,
-    login_count integer DEFAULT 0 NOT NULL
+    login_count integer DEFAULT 0 NOT NULL,
+    user_id integer DEFAULT 0 NOT NULL
 );
 
 
@@ -4655,6 +4678,15 @@
 
 
 
+ALTER TABLE ONLY ezurlalias_ml_incr
+    ADD CONSTRAINT ezurlalias_ml_incr_pkey PRIMARY KEY (id);
+
+
+
+
+
+
+
 ALTER TABLE ONLY ezurlwildcard
     ADD CONSTRAINT ezurlwildcard_pkey PRIMARY KEY (id);
 
Index: kernel/sql/postgresql/setval.sql
===================================================================
--- kernel/sql/postgresql/setval.sql	(revision 22686)
+++ kernel/sql/postgresql/setval.sql	(working copy)
@@ -76,3 +76,4 @@
 SELECT setval('ezworkflow_process_s',max(id)+1) FROM ezworkflow_process;
 SELECT setval('ezworkflow_s',max(id)+1) FROM ezworkflow;
 SELECT setval('ezurlwildcard_s',max(id)+1) FROM ezurlwildcard;
+SELECT setval('ezurlalias_ml_incr_s',max(id)+1) FROM ezurlalias_ml_incr;
Index: share/db_data.dba
===================================================================
--- share/db_data.dba	(revision 22686)
+++ share/db_data.dba	(working copy)
@@ -13703,6 +13703,152 @@
       ),
     ),
   ),
+  'ezurlalias_ml_incr' => 
+  array (
+    'fields' => 
+    array (
+      0 => 'id',
+    ),
+    'rows' => 
+    array (
+      0 => 
+      array (
+        0 => '1',
+      ),
+      1 => 
+      array (
+        0 => '2',
+      ),
+      2 => 
+      array (
+        0 => '3',
+      ),
+      3 => 
+      array (
+        0 => '4',
+      ),
+      4 => 
+      array (
+        0 => '5',
+      ),
+      5 => 
+      array (
+        0 => '6',
+      ),
+      6 => 
+      array (
+        0 => '7',
+      ),
+      7 => 
+      array (
+        0 => '8',
+      ),
+      8 => 
+      array (
+        0 => '9',
+      ),
+      9 => 
+      array (
+        0 => '10',
+      ),
+      10 => 
+      array (
+        0 => '11',
+      ),
+      11 => 
+      array (
+        0 => '12',
+      ),
+      12 => 
+      array (
+        0 => '13',
+      ),
+      13 => 
+      array (
+        0 => '14',
+      ),
+      14 => 
+      array (
+        0 => '15',
+      ),
+      15 => 
+      array (
+        0 => '16',
+      ),
+      16 => 
+      array (
+        0 => '17',
+      ),
+      17 => 
+      array (
+        0 => '18',
+      ),
+      18 => 
+      array (
+        0 => '19',
+      ),
+      19 => 
+      array (
+        0 => '20',
+      ),
+      20 => 
+      array (
+        0 => '21',
+      ),
+      21 => 
+      array (
+        0 => '22',
+      ),
+      22 => 
+      array (
+        0 => '24',
+      ),
+      23 => 
+      array (
+        0 => '25',
+      ),
+      24 => 
+      array (
+        0 => '26',
+      ),
+      25 => 
+      array (
+        0 => '27',
+      ),
+      26 => 
+      array (
+        0 => '28',
+      ),
+      27 => 
+      array (
+        0 => '29',
+      ),
+      28 => 
+      array (
+        0 => '30',
+      ),
+      29 => 
+      array (
+        0 => '31',
+      ),
+      30 => 
+      array (
+        0 => '32',
+      ),
+      31 => 
+      array (
+        0 => '33',
+      ),
+      32 => 
+      array (
+        0 => '34',
+      ),
+      33 => 
+      array (
+        0 => '35',
+      ),
+    ),
+  ),
   'ezuser' => 
   array (
     'fields' => 
Index: share/db_schema.dba
===================================================================
--- share/db_schema.dba	(revision 22686)
+++ share/db_schema.dba	(working copy)
@@ -6712,6 +6712,29 @@
       ),
     ),
   ),
+  'ezurlalias_ml_incr' => 
+  array (
+    'name' => 'ezurlalias_ml_incr',
+    'fields' => 
+    array (
+      'id' => 
+      array (
+        'type' => 'auto_increment',
+        'default' => false,
+      ),
+    ),
+    'indexes' => 
+    array (
+      'PRIMARY' => 
+      array (
+        'type' => 'primary',
+        'fields' => 
+        array (
+          0 => 'id',
+        ),
+      ),
+    ),
+  ),
   'ezurlwildcard' => 
   array (
     'name' => 'ezurlwildcard',
@@ -7019,14 +7042,14 @@
         'not_null' => '1',
         'default' => 0,
       ),
-      'user_id' => 
+      'login_count' => 
       array (
         'length' => 11,
         'type' => 'int',
         'not_null' => '1',
         'default' => 0,
       ),
-      'login_count' => 
+      'user_id' => 
       array (
         'length' => 11,
         'type' => 'int',
@@ -7810,4 +7833,4 @@
   ),
 );
 
-?>
+?>
\ No newline at end of file
Index: update/common/scripts/4.1/initurlaliasmlid.php
===================================================================
--- update/common/scripts/4.1/initurlaliasmlid.php	(revision 0)
+++ update/common/scripts/4.1/initurlaliasmlid.php	(revision 0)
@@ -0,0 +1,57 @@
+#!/usr/bin/env php
+<?php
+
+require 'autoload.php';
+
+$cli = eZCLI::instance();
+
+$scriptSettings = array();
+$scriptSettings['description'] = 'Initialize the ezurlalias_ml_incr table';
+$scriptSettings['use-session'] = true;
+$scriptSettings['use-modules'] = true;
+$scriptSettings['use-extensions'] = true;
+
+$script = eZScript::instance( $scriptSettings );
+$script->startup();
+
+$config = '';
+$argumentConfig = '';
+$optionHelp = false;
+$arguments = false;
+$useStandardOptions = true;
+
+$options = $script->getOptions( $config, $argumentConfig, $optionHelp, $arguments, $useStandardOptions );
+$script->initialize();
+
+include_once( 'kernel/classes/ezurlaliasmlid.php' );
+
+$db = eZDB::instance();
+
+$maxIDs = $db->arrayQuery( 'SELECT MAX( id ) AS max_id FROM ezurlalias_ml', array( 'column' => 'max_id' ) );
+
+$maxID = (int)$maxIDs[0];
+$cli->output( "highest ID in ezurlalias_ml table: $maxID" );
+
+$autoInc = $maxID + 1;
+
+$cli->output( 'Truncating ezurlalias_ml_incr table' );
+$db->query( 'TRUNCATE TABLE ezurlalias_ml_incr' );
+
+$cli->output( 'Setting next auto_increment value to highest existing ID + 1' );
+
+if ( $db instanceof eZMySQLDB || $db instanceof eZMySQLiDB )
+{
+    $db->query( "ALTER TABLE ezurlalias_ml_incr AUTO_INCREMENT=$autoInc" );
+}
+else
+{
+    $db->query( "DROP SEQUENCE ezurlalias_ml_incr_s" );
+    $db->query( "CREATE SEQUENCE ezurlalias_ml_incr_s MINVALUE $autoInc" );
+}
+
+$cli->output( 'Inserting existing IDs into ezurlalias_ml_incr table' );
+$db->query( "INSERT INTO ezurlalias_ml_incr (id) SELECT DISTINCT id FROM ezurlalias_ml" );
+
+$script->shutdown( 0 );
+
+?>
\ No newline at end of file

Property changes on: update\common\scripts\4.1\initurlaliasmlid.php
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:eol-style
   + native

Index: update/database/mysql/4.1/unstable/dbupdate-4.0.0-to-4.1.0alpha1.sql
===================================================================
--- update/database/mysql/4.1/unstable/dbupdate-4.0.0-to-4.1.0alpha1.sql	(revision 22686)
+++ update/database/mysql/4.1/unstable/dbupdate-4.0.0-to-4.1.0alpha1.sql	(working copy)
@@ -76,3 +76,7 @@
 
 ALTER TABLE ezorder_item CHANGE vat_value vat_value FLOAT NOT NULL default 0;
 
+CREATE TABLE ezurlalias_ml_incr (
+  id int(11) NOT NULL auto_increment,
+  PRIMARY KEY  (id)
+) TYPE=InnoDB;
Index: update/database/postgresql/4.1/unstable/dbupdate-4.0.0-to-4.1.0alpha1.sql
===================================================================
--- update/database/postgresql/4.1/unstable/dbupdate-4.0.0-to-4.1.0alpha1.sql	(revision 22686)
+++ update/database/postgresql/4.1/unstable/dbupdate-4.0.0-to-4.1.0alpha1.sql	(working copy)
@@ -107,3 +107,17 @@
 ALTER TABLE ezorder_item ALTER COLUMN vat_value TYPE double precision;
 ALTER TABLE ezorder_item ALTER COLUMN vat_value SET DEFAULT 0;
 ALTER TABLE ezorder_item ALTER COLUMN vat_value SET NOT NULL;
+
+CREATE SEQUENCE ezurlalias_ml_incr_s
+    START 1
+    INCREMENT 1
+    MAXVALUE 9223372036854775807
+    MINVALUE 1
+    CACHE 1;
+    
+CREATE TABLE ezurlalias_ml_incr (
+    id integer DEFAULT nextval('ezurlalias_ml_incr_s'::text) NOT NULL
+);
+
+ALTER TABLE ONLY ezurlalias_ml_incr
+    ADD CONSTRAINT ezurlalias_ml_incr_pkey PRIMARY KEY (id);
