Skip to content

Commit

Permalink
Fix install languages and discover extension for mssql.
Browse files Browse the repository at this point in the history
Mysql strict mode - install languages fix
Postgresql - reinstall languages fix
Mssql - install and reinstall and discover extension fix
  • Loading branch information
Tomasz Narloch committed Mar 4, 2017
1 parent c27905f commit e8c27d1
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 32 deletions.
@@ -0,0 +1,5 @@
ALTER TABLE `#__languages` MODIFY `asset_id` int(10) unsigned NOT NULL DEFAULT 0;
ALTER TABLE `#__menu_types` MODIFY `asset_id` int(10) unsigned NOT NULL DEFAULT 0;

ALTER TABLE `#__content` MODIFY `xreference` varchar(50) NOT NULL DEFAULT '';
ALTER TABLE `#__newsfeeds` MODIFY `xreference` varchar(50) NOT NULL DEFAULT '';
@@ -0,0 +1,5 @@
ALTER TABLE "#__extensions" ALTER COLUMN "custom_data" DROP DEFAULT;
ALTER TABLE "#__extensions" ALTER COLUMN "system_data" DROP DEFAULT;
ALTER TABLE "#__updates" ALTER COLUMN "data" DROP DEFAULT;

ALTER TABLE "#__newsfeeds" ALTER COLUMN "xreference" SET DEFAULT '';
@@ -0,0 +1,31 @@
CREATE PROCEDURE "#removeDefault"
(
@table NVARCHAR(100),
@column NVARCHAR(100)
)
AS
BEGIN
DECLARE @constraintName AS nvarchar(100)
DECLARE @constraintQuery AS nvarchar(1000)
SELECT @constraintName = name FROM sys.default_constraints
WHERE parent_object_id = object_id(@table)
AND parent_column_id = columnproperty(object_id(@table), @column, 'ColumnId')
SET @constraintQuery = 'ALTER TABLE [' + @table + '] DROP CONSTRAINT [' + @constraintName + ']'
EXECUTE sp_executesql @constraintQuery
END;

EXECUTE "#removeDefault" "#__extensions", 'system_data';
EXECUTE "#removeDefault" "#__updates", 'data';

ALTER TABLE "#__content" ADD DEFAULT ('') FOR "xreference";
ALTER TABLE "#__newsfeeds" ADD DEFAULT ('') FOR "xreference";

-- Delete wrong unique index
DROP INDEX "idx_access" ON "#__languages";

-- Add missing unique index
ALTER TABLE "#__languages" ADD CONSTRAINT "#__languages$idx_langcode" UNIQUE ("lang_code") ON [PRIMARY];

-- Add missing index keys
CREATE INDEX "idx_access" ON "#__languages" ("access");
CREATE INDEX "idx_ordering" ON "#__languages" ("ordering");
1 change: 1 addition & 0 deletions administrator/components/com_installer/models/discover.php
Expand Up @@ -166,6 +166,7 @@ public function discover()
if (!array_key_exists($key, $extensions))
{
// Put it into the table
$result->check();
$result->store();
}
}
Expand Down
12 changes: 6 additions & 6 deletions installation/sql/mysql/joomla.sql
Expand Up @@ -343,7 +343,7 @@ CREATE TABLE IF NOT EXISTS `#__content` (
`metadata` text NOT NULL,
`featured` tinyint(3) unsigned NOT NULL DEFAULT 0 COMMENT 'Set if article is featured.',
`language` char(7) NOT NULL COMMENT 'The language code for the article.',
`xreference` varchar(50) NOT NULL COMMENT 'A reference to enable linkages to external data sets.',
`xreference` varchar(50) NOT NULL DEFAULT '' COMMENT 'A reference to enable linkages to external data sets.',
PRIMARY KEY (`id`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
Expand Down Expand Up @@ -655,7 +655,7 @@ INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `elem

CREATE TABLE IF NOT EXISTS `#__fields` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`asset_id` int(10) NOT NULL DEFAULT 0,
`asset_id` int(10) unsigned NOT NULL DEFAULT 0,
`context` varchar(255) NOT NULL DEFAULT '',
`group_id` int(10) NOT NULL DEFAULT 0,
`title` varchar(255) NOT NULL DEFAULT '',
Expand Down Expand Up @@ -707,7 +707,7 @@ CREATE TABLE `#__fields_categories` (

CREATE TABLE IF NOT EXISTS `#__fields_groups` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`asset_id` int(10) NOT NULL DEFAULT 0,
`asset_id` int(10) unsigned NOT NULL DEFAULT 0,
`context` varchar(255) NOT NULL DEFAULT '',
`title` varchar(255) NOT NULL DEFAULT '',
`note` varchar(255) NOT NULL DEFAULT '',
Expand Down Expand Up @@ -1307,7 +1307,7 @@ CREATE TABLE IF NOT EXISTS `#__finder_types` (

CREATE TABLE IF NOT EXISTS `#__languages` (
`lang_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`asset_id` int(11) NOT NULL,
`asset_id` int(10) unsigned NOT NULL DEFAULT 0,
`lang_code` char(7) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
`title` varchar(50) NOT NULL,
`title_native` varchar(50) NOT NULL,
Expand Down Expand Up @@ -1411,7 +1411,7 @@ INSERT INTO `#__menu` (`id`, `menutype`, `title`, `alias`, `note`, `path`, `link

CREATE TABLE IF NOT EXISTS `#__menu_types` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`asset_id` int(11) NOT NULL,
`asset_id` int(10) unsigned NOT NULL DEFAULT 0,
`menutype` varchar(24) NOT NULL,
`title` varchar(48) NOT NULL,
`description` varchar(255) NOT NULL DEFAULT '',
Expand Down Expand Up @@ -1577,7 +1577,7 @@ CREATE TABLE IF NOT EXISTS `#__newsfeeds` (
`metakey` text NOT NULL,
`metadesc` text NOT NULL,
`metadata` text NOT NULL,
`xreference` varchar(50) NOT NULL COMMENT 'A reference to enable linkages to external data sets.',
`xreference` varchar(50) NOT NULL DEFAULT '' COMMENT 'A reference to enable linkages to external data sets.',
`publish_up` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`description` text NOT NULL,
Expand Down
8 changes: 4 additions & 4 deletions installation/sql/postgresql/joomla.sql
Expand Up @@ -479,8 +479,8 @@ CREATE TABLE "#__extensions" (
"protected" smallint DEFAULT 0 NOT NULL,
"manifest_cache" text NOT NULL,
"params" text NOT NULL,
"custom_data" text DEFAULT '' NOT NULL,
"system_data" text DEFAULT '' NOT NULL,
"custom_data" text NOT NULL,
"system_data" text NOT NULL,
"checked_out" integer DEFAULT 0 NOT NULL,
"checked_out_time" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"ordering" bigint DEFAULT 0,
Expand Down Expand Up @@ -1548,7 +1548,7 @@ CREATE TABLE "#__newsfeeds" (
"metakey" text NOT NULL,
"metadesc" text NOT NULL,
"metadata" text NOT NULL,
"xreference" varchar(50) NOT NULL,
"xreference" varchar(50) NOT NULL DEFAULT '',
"publish_up" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"publish_down" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"description" text NOT NULL,
Expand Down Expand Up @@ -1863,7 +1863,7 @@ CREATE TABLE "#__updates" (
"folder" varchar(20) DEFAULT '',
"client_id" smallint DEFAULT 0,
"version" varchar(32) DEFAULT '',
"data" text DEFAULT '' NOT NULL,
"data" text NOT NULL,
"detailsurl" text NOT NULL,
"infourl" text NOT NULL,
"extra_query" varchar(1000) DEFAULT '',
Expand Down
32 changes: 13 additions & 19 deletions installation/sql/sqlazure/joomla.sql
Expand Up @@ -491,7 +491,7 @@ CREATE TABLE "#__content" (
"metadata" nvarchar(max) NOT NULL,
"featured" tinyint NOT NULL DEFAULT 0,
"language" nvarchar(7) NOT NULL,
"xreference" nvarchar(50) NOT NULL,
"xreference" nvarchar(50) NOT NULL DEFAULT '',
CONSTRAINT "PK_#__content_id" PRIMARY KEY CLUSTERED
(
"id" ASC
Expand Down Expand Up @@ -671,7 +671,7 @@ CREATE TABLE "#__extensions" (
"manifest_cache" nvarchar(max) NOT NULL,
"params" nvarchar(max) NOT NULL,
"custom_data" nvarchar(max) NOT NULL,
"system_data" nvarchar(max) NOT NULL DEFAULT '',
"system_data" nvarchar(max) NOT NULL,
"checked_out" bigint NOT NULL DEFAULT 0,
"checked_out_time" datetime2(0) NOT NULL DEFAULT '1900-01-01 00:00:00',
"ordering" int NULL DEFAULT 0,
Expand Down Expand Up @@ -880,7 +880,7 @@ SET IDENTITY_INSERT "#__extensions" OFF;

CREATE TABLE "#__fields" (
"id" int IDENTITY(1,1) NOT NULL,
"asset_id" int NOT NULL DEFAULT 0,
"asset_id" bigint NOT NULL DEFAULT 0,
"context" nvarchar(255) NOT NULL DEFAULT '',
"group_id" int NOT NULL DEFAULT 0,
"title" nvarchar(255) NOT NULL DEFAULT '',
Expand Down Expand Up @@ -949,7 +949,7 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW

CREATE TABLE "#__fields_groups" (
"id" int IDENTITY(1,1) NOT NULL,
"asset_id" int NOT NULL DEFAULT 0,
"asset_id" bigint NOT NULL DEFAULT 0,
"context" nvarchar(255) NOT NULL DEFAULT '',
"title" nvarchar(255) NOT NULL DEFAULT '',
"note" nvarchar(255) NOT NULL DEFAULT '',
Expand Down Expand Up @@ -1890,20 +1890,14 @@ CREATE TABLE "#__languages" (
"published" int NOT NULL DEFAULT 0,
"access" bigint NOT NULL DEFAULT 0,
"ordering" int NOT NULL DEFAULT 0,
CONSTRAINT "PK_#__languages_lang_id" PRIMARY KEY CLUSTERED
(
"lang_id" ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
CONSTRAINT "#__languages$idx_sef" UNIQUE NONCLUSTERED
(
"sef" ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];
CONSTRAINT "PK_#__languages_lang_id" PRIMARY KEY ("lang_id") ON [PRIMARY],
CONSTRAINT "#__languages$idx_sef" UNIQUE ("sef") ON [PRIMARY],
CONSTRAINT "#__languages$idx_langcode" UNIQUE ("lang_code") ON [PRIMARY]
)
ON [PRIMARY];

CREATE UNIQUE INDEX "idx_access" ON "#__languages"
(
"access" ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF);
CREATE INDEX "idx_ordering" ON "#__languages" ("ordering");
CREATE INDEX "idx_access" ON "#__languages" ("access");

--
-- Dumping data for table `#__languages`
Expand Down Expand Up @@ -2247,7 +2241,7 @@ CREATE TABLE "#__newsfeeds" (
"metakey" nvarchar(max) NOT NULL,
"metadesc" nvarchar(max) NOT NULL,
"metadata" nvarchar(max) NOT NULL,
"xreference" nvarchar(50) NOT NULL,
"xreference" nvarchar(50) NOT NULL DEFAULT '',
"publish_up" datetime2(0) NOT NULL DEFAULT '1900-01-01 00:00:00',
"publish_down" datetime2(0) NOT NULL DEFAULT '1900-01-01 00:00:00',
"description" nvarchar(max) NOT NULL,
Expand Down Expand Up @@ -2735,7 +2729,7 @@ CREATE TABLE "#__updates" (
"folder" nvarchar(20) DEFAULT '',
"client_id" smallint DEFAULT 0,
"version" nvarchar(32) DEFAULT '',
"data" nvarchar(max) NOT NULL DEFAULT '',
"data" nvarchar(max) NOT NULL,
"detailsurl" nvarchar(max) NOT NULL,
"infourl" nvarchar(max) NOT NULL,
"extra_query" nvarchar(1000) NULL DEFAULT '',
Expand Down
7 changes: 4 additions & 3 deletions libraries/cms/installer/adapter/language.php
Expand Up @@ -292,7 +292,7 @@ protected function _install($cname, $basePath, $clientId, &$element)
$row->set('params', $this->parent->getParams());
$row->set('manifest_cache', $this->parent->generateManifestCache());

if (!$row->store())
if (!$row->check() || !$row->store())
{
// Install failed, roll back changes
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError()));
Expand Down Expand Up @@ -537,7 +537,7 @@ public function update()

// Update an entry to the extension table
$row = JTable::getInstance('extension');
$eid = $row->find(array('element' => strtolower($this->get('tag')), 'type' => 'language', 'client_id' => $clientId));
$eid = $row->find(array('element' => $this->get('tag'), 'type' => 'language', 'client_id' => $clientId));

if ($eid)
{
Expand All @@ -564,7 +564,7 @@ public function update()
// Clean installed languages cache.
JFactory::getCache()->clean('com_languages');

if (!$row->store())
if (!$row->check() || !$row->store())
{
// Install failed, roll back changes
$this->parent->abort(JText::sprintf('JLIB_INSTALLER_ABORT', $row->getError()));
Expand Down Expand Up @@ -794,6 +794,7 @@ public function discover_install()
// @todo remove code: $this->parent->extension->params = $this->parent->getParams();
try
{
$this->parent->extension->check();
$this->parent->extension->store();
}
catch (RuntimeException $e)
Expand Down
13 changes: 13 additions & 0 deletions libraries/joomla/table/extension.php
Expand Up @@ -49,6 +49,19 @@ public function check()
return false;
}

if (!$this->extension_id)
{
if (!$this->custom_data)
{
$this->custom_data = '';
}

if (!$this->system_data)
{
$this->system_data = '';
}
}

return true;
}

Expand Down
5 changes: 5 additions & 0 deletions libraries/joomla/table/update.php
Expand Up @@ -49,6 +49,11 @@ public function check()
return false;
}

if (!$this->update_id && !$this->data)
{
$this->data = '';
}

return true;
}

Expand Down
1 change: 1 addition & 0 deletions libraries/joomla/updater/updater.php
Expand Up @@ -157,6 +157,7 @@ public function findUpdates($eid = 0, $cacheTimeout = 0, $minimum_stability = se
/** @var JTableUpdate $update */
foreach ($updateObjects as $update)
{
$update->check();
$update->store();
}
}
Expand Down

0 comments on commit e8c27d1

Please sign in to comment.