Robert Vogel has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/192523

Change subject: SQLite compatibility
......................................................................

SQLite compatibility

added support for SQLite and modified mysql statements for compatibility
with SQLite

Change-Id: I9d06d46fa2585487b73e80ab4a411a4be229f537
(cherry picked from commit c5e6ef1e5347e6cd3257d3f7fcd7905246d886b2)
---
M InsertFile/includes/InsertFileAJAXBackend.php
M NamespaceManager/NamespaceManager.class.php
M PageTemplates/db/PageTemplates.sql
M PermissionManager/db/PermissionManager.sql
M Readers/Readers.class.php
M Review/Review.class.php
M Review/db/mysql/review.sql
M SaferEdit/SaferEdit.class.php
M SaferEdit/db/mysql/SaferEdit.sql
M ShoutBox/ShoutBox.class.php
M ShoutBox/db/mysql/ShoutBox.sql
M WhoIsOnline/WhoIsOnline.class.php
M WhoIsOnline/whoisonline.sql
13 files changed, 42 insertions(+), 41 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/23/192523/1

diff --git a/InsertFile/includes/InsertFileAJAXBackend.php 
b/InsertFile/includes/InsertFileAJAXBackend.php
index b545e37..3f81120 100644
--- a/InsertFile/includes/InsertFileAJAXBackend.php
+++ b/InsertFile/includes/InsertFileAJAXBackend.php
@@ -122,7 +122,7 @@
 
                $dbr = wfGetDB( DB_SLAVE );
 
-               if ( $wgDBtype == 'mysql' ) {
+               if ( $wgDBtype == 'mysql' || $wgDBtype == 'sqlite' ) {
                        if ( $type == 'image' ) {
                                $tbl = $dbr->tableName( 'image' );
                                $sql = "SELECT tmp.rank, tmp.img_name FROM
@@ -283,21 +283,21 @@
                        $sql =
                                "SELECT * FROM
                                        (
-                                               SELECT i.img_name, i.img_size, 
i.img_width, i.img_height, (ROUND(TO_DATE(TO_CHAR(i.img_timestamp, 
'YYYYMMDDHH24MISS'), 'YYYYMMDDHH24MISS') - TO_DATE('19700101', 
'YYYYMMDDHH24MISS')) * 86400) AS img_timestamp,
+                                               SELECT i.img_name, i.img_size, 
i.img_width, i.img_height, i.img_timestamp,
                                                                row_number() 
over (ORDER BY {$sSort}) rnk
                                                FROM {$sImageTable} i
                                                WHERE {$sConds}
                                        )
                                WHERE rnk BETWEEN {$sStart}+1 AND " . ( $sStart 
+ $sLimit );
                } elseif ( $wgDBtype == 'postgres' ) {
-                       $sql = "SELECT i.img_name, i.img_size, i.img_width, 
i.img_height, ROUND(DATE_PART('epoch', i.img_timestamp)) as img_timestamp
+                       $sql = "SELECT i.img_name, i.img_size, i.img_width, 
i.img_height, i.img_timestamp
                                FROM {$sImageTable} i
                                WHERE {$sConds}
                                ORDER BY {$sSort}
                                OFFSET {$sStart}
                                LIMIT {$sLimit}";
                } else {
-                       $sql = "SELECT i.img_name, i.img_size, i.img_width, 
i.img_height, UNIX_TIMESTAMP(i.img_timestamp) as img_timestamp
+                       $sql = "SELECT i.img_name, i.img_size, i.img_width, 
i.img_height, i.img_timestamp
                                FROM {$sImageTable} i
                                WHERE {$sConds}
                                ORDER BY {$sSort}
@@ -330,7 +330,7 @@
                                'name'    => $row->img_name,
                                'url'     => $url,
                                'size'    => $row->img_size,
-                               'lastmod' => $row->img_timestamp,
+                               'lastmod' => wfTimestamp(TS_UNIX, 
$row->img_timestamp),
                                'width'   => $row->img_width,
                                'height'  => $row->img_height
                        );
@@ -351,7 +351,7 @@
                //nonstandard.
                $sFormat = "LOWER(CONVERT($sTableName USING 'UTF8')) LIKE %s";
 
-               if( $dbType == 'oracle' || $dbType == 'postgres') {
+               if( $dbType == 'oracle' || $dbType == 'postgres' || $dbType == 
'sqlite') {
                        $sFormat = "LOWER($sTableName) LIKE %s";
                }
                $dbr = wfGetDB( DB_SLAVE );
diff --git a/NamespaceManager/NamespaceManager.class.php 
b/NamespaceManager/NamespaceManager.class.php
index 3410fae..a73ab1c 100644
--- a/NamespaceManager/NamespaceManager.class.php
+++ b/NamespaceManager/NamespaceManager.class.php
@@ -147,7 +147,7 @@
                                'rev_content_model',
                                $dir . 
'bs_namespacemanager_backup_revision.patch2.pg.sql'
                        );
-               } else {
+               } elseif ( $wgDBtype != 'sqlite' ) { /* Do not apply patches to 
sqlite */
                        $updater->addExtensionField(
                                'bs_namespacemanager_backup_page',
                                'page_content_model',
diff --git a/PageTemplates/db/PageTemplates.sql 
b/PageTemplates/db/PageTemplates.sql
index f711fce..f0f6a01 100644
--- a/PageTemplates/db/PageTemplates.sql
+++ b/PageTemplates/db/PageTemplates.sql
@@ -11,12 +11,11 @@
 -- @filesource
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_pagetemplate (
-  pt_id                 int(10) unsigned    NOT NULL AUTO_INCREMENT,
+  pt_id                 int(10) unsigned    NOT NULL PRIMARY KEY 
AUTO_INCREMENT,
   pt_label              varchar(255)        NOT NULL DEFAULT '',
   pt_desc               varchar(255)        NOT NULL DEFAULT '',
   pt_target_namespace   int(11)             NOT NULL DEFAULT -99,
   pt_template_title     varbinary(255)      NOT NULL DEFAULT '', /* foreign 
key to page_title */
   pt_template_namespace int(11)             NOT NULL DEFAULT 0,  /* foreign 
key to page_namespace */
-  pt_sid                int(10) unsigned    NOT NULL DEFAULT 0,
-  UNIQUE KEY pt_id (pt_id)
+  pt_sid                int(10) unsigned    NOT NULL DEFAULT 0
 )/*$wgDBTableOptions*/;
diff --git a/PermissionManager/db/PermissionManager.sql 
b/PermissionManager/db/PermissionManager.sql
index 24c1d6e..30bec2d 100644
--- a/PermissionManager/db/PermissionManager.sql
+++ b/PermissionManager/db/PermissionManager.sql
@@ -11,9 +11,8 @@
 -- @filesource
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_permission_templates (
-  `tpl_id` int(10) unsigned NOT NULL auto_increment,
-  `tpl_name` varchar(100) collate utf8_bin NOT NULL,
+  `tpl_id` int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
+  `tpl_name` varchar(255) NOT NULL,
   `tpl_data` blob NOT NULL,
-  `tpl_description` text collate utf8_bin NOT NULL,
-  PRIMARY KEY  (`tpl_id`)
+  `tpl_description` mediumblob NOT NULL
 )/*$wgDBTableOptions*/;
diff --git a/Readers/Readers.class.php b/Readers/Readers.class.php
index 27966a3..de4b094 100644
--- a/Readers/Readers.class.php
+++ b/Readers/Readers.class.php
@@ -139,7 +139,6 @@
                );
 
                $aNewRow = array();
-               $aNewRow['readers_id'] = 0;
                $aNewRow['readers_user_id'] = $oUser->getId();
                $aNewRow['readers_user_name'] = $oUser->getName();
                $aNewRow['readers_page_id'] = $oTitle->getArticleID();
@@ -417,4 +416,4 @@
                return json_encode( $aPages );
        }
 
-}
\ No newline at end of file
+}
diff --git a/Review/Review.class.php b/Review/Review.class.php
index f51947a..dc387ed 100644
--- a/Review/Review.class.php
+++ b/Review/Review.class.php
@@ -287,6 +287,11 @@
                        $wgExtNewIndexes[] = array('bs_review_steps', 
'revs_user_id', $sDir . 'db/oracle/review.patch.user_id.index.oci.sql');
                        $wgExtNewIndexes[] = array('bs_review_steps', 
'revs_status', $sDir . 'db/oracle/review.patch.status.index.oci.sql');
                        $wgExtNewIndexes[] = array('bs_review_templates', 
'revt_name', $sDir . 'db/oracle/review.patch.name.index.oci.sql');
+               } elseif ($wgDBtype == 'sqlite') {
+                       $updater->addExtensionTable(
+                               'bs_review',
+                               $sDir . 'db/mysql/review.sql'
+                       );
                }
                return true;
        }
diff --git a/Review/db/mysql/review.sql b/Review/db/mysql/review.sql
index bc2f190..ab44a1c 100644
--- a/Review/db/mysql/review.sql
+++ b/Review/db/mysql/review.sql
@@ -11,39 +11,34 @@
 -- @filesource
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_review (
-  rev_id         smallint(5) unsigned NOT NULL AUTO_INCREMENT,
+  rev_id         smallint(5) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
   rev_pid        smallint(5) unsigned NOT NULL DEFAULT '0',
   rev_editable   tinyint(3) unsigned  NOT NULL DEFAULT '0',
   rev_sequential tinyint(3) unsigned  NOT NULL DEFAULT '0',
   rev_abortable  tinyint(3) unsigned  NOT NULL DEFAULT '0',
   rev_startdate  date                 NOT NULL DEFAULT '2000-01-01',
   rev_enddate    date                 NOT NULL DEFAULT '2000-01-01',
-  rev_owner      int(5) unsigned      NOT NULL,
-  PRIMARY KEY (rev_id),
-  UNIQUE KEY rev_id (rev_id)
+  rev_owner      int(5) unsigned      NOT NULL
 ) /*$wgDBTableOptions*/;
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_review_steps (
-  revs_id        smallint(5)  unsigned NOT NULL AUTO_INCREMENT,
+  revs_id        smallint(5)  unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
   revs_review_id smallint(5)  unsigned NOT NULL DEFAULT '0',
   revs_user_id   smallint(6)           NOT NULL DEFAULT '0',
   revs_status    tinyint(4)            NOT NULL DEFAULT '-1',
   revs_sort_id   tinyint(3)   unsigned NOT NULL DEFAULT '0',
   revs_comment   varchar(255)          DEFAULT NULL,
   revs_delegate_to   smallint(6)       NOT NULL DEFAULT '0',
-  revs_timestamp timestamp,
-  PRIMARY KEY (revs_id),
-  UNIQUE KEY revs_id (revs_id)
+  revs_timestamp timestamp
 ) /*$wgDBTableOptions*/;
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_review_templates (
-  revt_id         int(10) unsigned     NOT NULL AUTO_INCREMENT,
+  revt_id         int(10) unsigned     NOT NULL PRIMARY KEY AUTO_INCREMENT,
   revt_name       varchar(255)         NOT NULL,
   revt_owner      int(5) unsigned      NOT NULL,
   revt_user       varchar(255)         NOT NULL,
   revt_editable   tinyint(3) unsigned  NOT NULL DEFAULT '0',
   revt_sequential tinyint(3) unsigned  NOT NULL DEFAULT '0',
   revt_abortable  tinyint(3) unsigned  NOT NULL DEFAULT '0',
-  revt_public     tinyint(1)           NOT NULL,
-  PRIMARY KEY (revt_id)
+  revt_public     tinyint(1)           NOT NULL
 ) /*$wgDBTableOptions*/;
\ No newline at end of file
diff --git a/SaferEdit/SaferEdit.class.php b/SaferEdit/SaferEdit.class.php
index af19628..74d70d8 100644
--- a/SaferEdit/SaferEdit.class.php
+++ b/SaferEdit/SaferEdit.class.php
@@ -130,11 +130,14 @@
                global $wgDBtype, $wgExtNewTables, $wgExtNewIndexes;
                $sDir = __DIR__.DS.'db'.DS.$wgDBtype.DS;
 
-               if( $wgDBtype == 'mysql' ) {
+               if( $wgDBtype == 'mysql') {
                        $wgExtNewTables[]  = array( 'bs_saferedit', $sDir . 
'SaferEdit.sql' );
                        $wgExtNewIndexes[] = array( 'bs_saferedit', 
'se_page_title',     $sDir . 'SaferEdit.patch.se_page_title.index.sql' );
                        $wgExtNewIndexes[] = array( 'bs_saferedit', 
'se_page_namespace', $sDir . 'SaferEdit.patch.se_page_namespace.index.sql' );
 
+               } elseif( $wgDBtype == 'sqlite' ) {
+                       $sDir = __DIR__.DS.'db'.DS.'mysql'.DS;
+                       $wgExtNewTables[]  = array( 'bs_saferedit', $sDir . 
'SaferEdit.sql' );
                } elseif( $wgDBtype == 'postgres' ) {
                        $wgExtNewTables[]  = array( 'bs_saferedit', $sDir . 
'SaferEdit.pg.sql' );
                        /*
@@ -577,4 +580,4 @@
 
                return true;
        }
-}
\ No newline at end of file
+}
diff --git a/SaferEdit/db/mysql/SaferEdit.sql b/SaferEdit/db/mysql/SaferEdit.sql
index 22a083a..d207945 100644
--- a/SaferEdit/db/mysql/SaferEdit.sql
+++ b/SaferEdit/db/mysql/SaferEdit.sql
@@ -11,13 +11,11 @@
 -- @filesource
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_saferedit (
-  se_id             int(10) unsigned NOT NULL auto_increment,
+  se_id             int(10) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
   se_user_name      varchar(255)     default NULL,             /* foreign key 
to user.user_name */
   se_page_title     varbinary(255)   default NULL,             /* foreign key 
to page.page_title */
   se_page_namespace int(11)          default 0,                /* foreign key 
to page.page_namespaec */
   se_edit_section   int(10)          default -1,
   se_timestamp      varchar(16)      default NULL,             /* YmdHis */
-  se_text           blob,
-  PRIMARY KEY  (se_id),
-  UNIQUE KEY se_id (se_id)
+  se_text           blob
 )/*$wgDBTableOptions*/;
\ No newline at end of file
diff --git a/ShoutBox/ShoutBox.class.php b/ShoutBox/ShoutBox.class.php
index 1549641..fce9549 100644
--- a/ShoutBox/ShoutBox.class.php
+++ b/ShoutBox/ShoutBox.class.php
@@ -134,7 +134,7 @@
                global $wgDBtype, $wgExtNewTables, $wgExtNewIndexes, 
$wgExtNewFields;
                $sDir = __DIR__ . DS;
 
-               if ( $wgDBtype == 'mysql' ) {
+               if ( $wgDBtype == 'mysql') {
                        $wgExtNewTables[] = array( 'bs_shoutbox', $sDir . 
'db/mysql/ShoutBox.sql' );
                        $wgExtNewIndexes[] = array( 'bs_shoutbox', 
'sb_page_id', $sDir . 'db/mysql/ShoutBox.patch.sb_page_id.index.sql' );
                        $wgExtNewFields[] = array( 'bs_shoutbox', 'sb_user_id', 
$sDir . 'db/mysql/ShoutBox.patch.sb_user_id.sql' );
@@ -144,6 +144,8 @@
                        $wgExtNewFields[] = array( 'bs_shoutbox', 'sb_title', 
$sDir . 'db/mysql/ShoutBox.patch.sb_title.sql' );
                        $wgExtNewFields[] = array( 'bs_shoutbox', 'sb_touched', 
$sDir . 'db/mysql/ShoutBox.patch.sb_touched.sql' );
                        $wgExtNewFields[] = array( 'bs_shoutbox', 
'sb_parent_id', $sDir . 'db/mysql/ShoutBox.patch.sb_parent_id.sql' );
+               } elseif ( $wgDBtype == 'sqlite' ) {
+                       $wgExtNewTables[] = array( 'bs_shoutbox', $sDir . 
'db/mysql/ShoutBox.sql' );
                } elseif ( $wgDBtype == 'postgres' ) {
                        $wgExtNewTables[] = array( 'bs_shoutbox', $sDir . 
'db/postgres/ShoutBox.pg.sql' );
                        $wgExtNewFields[] = array( 'bs_shoutbox', 
'sb_archived', $sDir . 'db/postgres/ShoutBox.patch.sb_archived.pg.sql' );
diff --git a/ShoutBox/db/mysql/ShoutBox.sql b/ShoutBox/db/mysql/ShoutBox.sql
index 7536896..887710d 100644
--- a/ShoutBox/db/mysql/ShoutBox.sql
+++ b/ShoutBox/db/mysql/ShoutBox.sql
@@ -11,7 +11,7 @@
 -- @filesource
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_shoutbox(
-       `sb_id`        int(5)           NOT NULL auto_increment,
+       `sb_id`        int(5)           NOT NULL PRIMARY KEY AUTO_INCREMENT,
        `sb_page_id`   int(10)          NOT NULL default 0,        /* foreign 
key to page.page_id */
        `sb_user_id`   int(10) unsigned NOT NULL default 0,        /* foreign 
key to user.user_id */
        `sb_timestamp` varchar(16)      NOT NULL default '',       /* timestamp 
YmdHis */
@@ -20,8 +20,7 @@
        `sb_archived`  BOOLEAN          NOT NULL default 0,
        `sb_title`     varbinary(255)   NOT NULL default '',
        `sb_touched`   varchar(14)      NOT NULL default '',
-       `sb_parent_id` int(5) unsigned  NOT NULL default 0,
-       PRIMARY KEY (`sb_id`)
+       `sb_parent_id` int(5) unsigned  NOT NULL default 0
 )/*$wgDBTableOptions*/;
 
 CREATE INDEX /*i*/sb_page_id ON /*$wgDBprefix*/bs_shoutbox (sb_page_id);
diff --git a/WhoIsOnline/WhoIsOnline.class.php 
b/WhoIsOnline/WhoIsOnline.class.php
index 0d72404..5e06509 100644
--- a/WhoIsOnline/WhoIsOnline.class.php
+++ b/WhoIsOnline/WhoIsOnline.class.php
@@ -143,6 +143,9 @@
                        $wgExtNewIndexes[] = array( 'bs_whoisonline', 
'wo_page_namespace', $sDir . 
'db/mysql/whoisonline.patch.wo_page_namespace.index.sql' );
                        $wgExtNewIndexes[] = array( 'bs_whoisonline', 
'wo_timestamp',      $sDir . 
'db/mysql/whoisonline.patch.wo_timestamp.index.sql' );
 
+               } elseif( $wgDBtype == 'sqlite' ) {
+                       $wgExtNewTables[] = array( 'bs_whoisonline', $sDir . 
'whoisonline.sql' );
+
                } elseif( $wgDBtype == 'postgres' ) {
 
                        $wgExtNewTables[] = array( 'bs_whoisonline', $sDir . 
'whoisonline.pg.sql' );
@@ -549,4 +552,4 @@
                return true;
        }
 
-}
\ No newline at end of file
+}
diff --git a/WhoIsOnline/whoisonline.sql b/WhoIsOnline/whoisonline.sql
index 910d90c..6e9ffe8 100644
--- a/WhoIsOnline/whoisonline.sql
+++ b/WhoIsOnline/whoisonline.sql
@@ -11,7 +11,7 @@
 -- @filesource
 
 CREATE TABLE IF NOT EXISTS /*$wgDBprefix*/bs_whoisonline (
-      wo_id             bigint(30) unsigned NOT NULL AUTO_INCREMENT,
+      wo_id             bigint(30) unsigned NOT NULL PRIMARY KEY 
AUTO_INCREMENT,
       wo_user_id        int(30)    unsigned NOT NULL,
       wo_user_name      varbinary(255)      NOT NULL DEFAULT '',
       wo_user_real_name varbinary(255)      NOT NULL DEFAULT '',
@@ -19,7 +19,6 @@
       wo_page_namespace int(11)             NOT NULL,
       wo_page_title     varbinary(255)      NOT NULL,
       wo_timestamp      int(11)    unsigned NOT NULL,
-      wo_action         varbinary(32)       NOT NULL,
-      PRIMARY KEY ( wo_id )
+      wo_action         varbinary(32)       NOT NULL
 ) /*$wgDBTableOptions*/
 COMMENT='BlueSpice: WhoIsOnline - Stores information on users activities';
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/192523
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9d06d46fa2585487b73e80ab4a411a4be229f537
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_23
Gerrit-Owner: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: Tr4nt0r <dennerl...@hallowelt.biz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to