allow hooks to have negative priority

This commit is contained in:
zotlabs 2016-10-12 20:04:19 -07:00
parent 9a2f86e9ad
commit facc6ee6b3
4 changed files with 17 additions and 4 deletions

View File

@ -47,7 +47,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '1.15' ); define ( 'STD_VERSION', '1.15' );
define ( 'ZOT_REVISION', '1.1' ); define ( 'ZOT_REVISION', '1.1' );
define ( 'DB_UPDATE_VERSION', 1183 ); define ( 'DB_UPDATE_VERSION', 1184 );
/** /**

View File

@ -504,10 +504,11 @@ CREATE TABLE IF NOT EXISTS `hook` (
`hook` char(255) NOT NULL DEFAULT '', `hook` char(255) NOT NULL DEFAULT '',
`file` char(255) NOT NULL DEFAULT '', `file` char(255) NOT NULL DEFAULT '',
`fn` char(255) NOT NULL DEFAULT '', `fn` char(255) NOT NULL DEFAULT '',
`priority` int(11) unsigned NOT NULL DEFAULT '0', `priority` smallint NOT NULL DEFAULT '0',
`hook_version` int(11) NOT NULL DEFAULT '0', `hook_version` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `hook` (`hook`), KEY `hook` (`hook`),
KEY `priority` (`priority`),
KEY `hook_version` (`hook_version`) KEY `hook_version` (`hook_version`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

View File

@ -492,13 +492,15 @@ CREATE TABLE "hook" (
"hook" text NOT NULL, "hook" text NOT NULL,
"file" text NOT NULL, "file" text NOT NULL,
"fn" text NOT NULL, "fn" text NOT NULL,
"priority" bigint NOT NULL DEFAULT '0', "priority" smallint NOT NULL DEFAULT '0',
"hook_version" smallint NOT NULL DEFAULT '0', "hook_version" smallint NOT NULL DEFAULT '0',
PRIMARY KEY ("id") PRIMARY KEY ("id")
); );
create index "hook_idx" on hook ("hook"); create index "hook_idx" on hook ("hook");
create index "hook_version_idx" on hook ("hook_version"); create index "hook_version_idx" on hook ("hook_version");
create index "hook_priority_idx" on hook ("priority");
CREATE TABLE "hubloc" ( CREATE TABLE "hubloc" (
"hubloc_id" serial NOT NULL, "hubloc_id" serial NOT NULL,
"hubloc_guid" text NOT NULL DEFAULT '', "hubloc_guid" text NOT NULL DEFAULT '',

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1183 ); define( 'UPDATE_VERSION' , 1184 );
/** /**
* *
@ -2444,3 +2444,13 @@ function update_r1182() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
return UPDATE_FAILED; return UPDATE_FAILED;
} }
function update_r1183() {
$r1 = q("alter table hook CHANGE priority priority smallint NOT NULL DEFAULT '0' ");
$r2 = q("create index priority on hook (priority)");
if($r1 && $r2)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}