r86741 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86740‎ | r86741 | r86742 >
Date:21:37, 22 April 2011
Author:brion
Status:ok
Tags:
Comment:
Breaking the 'math' table setup out to Math extension. Should be the last main step in extension-ification of the math options!

The 'math' table will no longer be created on a default install unless you've explicitly enabled the Math plugin at install time; the usual update.php procedure will add it in.

Postgres, Oracle, MSSQL, and DB2 variants are included -- broken out from the core files -- but have not been tested.

I know there has been some code duplication in parser test infrastructure but could only find one instance of the parser test temporary table setup to remove the 'math' table from (the extension adds it back via the hook). If the phpunit-based runner breaks, please track it down and fix it there too.
Modified paths:
  • /trunk/extensions/Math/Math.hooks.php (modified) (history)
  • /trunk/extensions/Math/Math.php (modified) (history)
  • /trunk/extensions/Math/db (added) (history)
  • /trunk/extensions/Math/db/math.db2.sql (added) (history)
  • /trunk/extensions/Math/db/math.mssql.sql (added) (history)
  • /trunk/extensions/Math/db/math.oracle.sql (added) (history)
  • /trunk/extensions/Math/db/math.pg.sql (added) (history)
  • /trunk/extensions/Math/db/math.sql (added) (history)
  • /trunk/phase3/maintenance/archives/patch-math.sql (deleted) (history)
  • /trunk/phase3/maintenance/ibm_db2/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/mssql/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/oracle/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/tests/parser/parserTest.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-math.sql
@@ -1,28 +0,0 @@
2 -
3 -
4 -DROP TABLE IF EXISTS /*$wgDBprefix*/math;
5 -CREATE TABLE /*$wgDBprefix*/math (
6 - -- Binary MD5 hash of the latex fragment, used as an identifier key.
7 - math_inputhash varbinary(16) NOT NULL,
8 -
9 - -- Not sure what this is, exactly...
10 - math_outputhash varbinary(16) NOT NULL,
11 -
12 - -- texvc reports how well it thinks the HTML conversion worked;
13 - -- if it's a low level the PNG rendering may be preferred.
14 - math_html_conservativeness tinyint NOT NULL,
15 -
16 - -- HTML output from texvc, if any
17 - math_html text,
18 -
19 - -- MathML output from texvc, if any
20 - math_mathml text,
21 -
22 - UNIQUE KEY math_inputhash (math_inputhash)
23 -
24 -) /*$wgDBTableOptions*/;
Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -399,15 +399,7 @@
400400 CREATE UNIQUE INDEX wl_user_namespace_title ON watchlist (wl_namespace, wl_title, wl_user);
401401 CREATE INDEX wl_user ON watchlist (wl_user);
402402
403 -CREATE TABLE math (
404 - math_inputhash BYTEA NOT NULL UNIQUE,
405 - math_outputhash BYTEA NOT NULL,
406 - math_html_conservativeness SMALLINT NOT NULL,
407 - math_html TEXT,
408 - math_mathml TEXT
409 -);
410403
411 -
412404 CREATE TABLE interwiki (
413405 iw_prefix TEXT NOT NULL UNIQUE,
414406 iw_url TEXT NOT NULL,
Index: trunk/phase3/maintenance/oracle/tables.sql
@@ -405,15 +405,6 @@
406406 CREATE INDEX &mw_prefix.watchlist_i01 ON &mw_prefix.watchlist (wl_namespace, wl_title);
407407
408408
409 -CREATE TABLE &mw_prefix.math (
410 - math_inputhash VARCHAR2(32) NOT NULL,
411 - math_outputhash VARCHAR2(32) NOT NULL,
412 - math_html_conservativeness NUMBER NOT NULL,
413 - math_html CLOB,
414 - math_mathml CLOB
415 -);
416 -CREATE UNIQUE INDEX &mw_prefix.math_u01 ON &mw_prefix.math (math_inputhash);
417 -
418409 CREATE TABLE &mw_prefix.searchindex (
419410 si_page NUMBER NOT NULL,
420411 si_title VARCHAR2(255) DEFAULT '' NOT NULL,
Index: trunk/phase3/maintenance/mssql/tables.sql
@@ -545,18 +545,6 @@
546546 );
547547 CREATE UNIQUE INDEX /*$wgDBprefix*/namespace_title ON /*$wgDBprefix*/watchlist(wl_namespace,wl_title);
548548
549 -CREATE TABLE /*$wgDBprefix*/math (
550 - math_inputhash varbinary(16) NOT NULL PRIMARY KEY,
551 - math_outputhash varbinary(16) NOT NULL,
552 - math_html_conservativeness tinyint NOT NULL,
553 - math_html NVARCHAR(MAX),
554 - math_mathml NVARCHAR(MAX),
555 -);
556 -
557549 -- Needs fulltext index.
558550 CREATE TABLE /*$wgDBprefix*/searchindex (
559551 si_page INT NOT NULL unique REFERENCES /*$wgDBprefix*/page(page_id) ON DELETE CASCADE,
Index: trunk/phase3/maintenance/ibm_db2/tables.sql
@@ -445,15 +445,6 @@
446446 CREATE UNIQUE INDEX wl_user_namespace_title ON watchlist (wl_namespace, wl_title, wl_user);
447447
448448
449 -CREATE TABLE math (
450 - math_inputhash VARCHAR(16) FOR BIT DATA NOT NULL UNIQUE,
451 - math_outputhash VARCHAR(16) FOR BIT DATA NOT NULL,
452 - math_html_conservativeness SMALLINT NOT NULL,
453 - math_html CLOB(64K) INLINE LENGTH 4096,
454 - math_mathml CLOB(64K) INLINE LENGTH 4096
455 -);
456 -
457 -
458449 CREATE TABLE interwiki (
459450 iw_prefix VARCHAR(32) NOT NULL UNIQUE,
460451 iw_url CLOB(64K) INLINE LENGTH 4096 NOT NULL,
Index: trunk/phase3/maintenance/tables.sql
@@ -1032,31 +1032,6 @@
10331033
10341034
10351035 --
1036 -CREATE TABLE /*_*/math (
1037 - -- Binary MD5 hash of the latex fragment, used as an identifier key.
1038 - math_inputhash varbinary(16) NOT NULL,
1039 -
1040 - -- Not sure what this is, exactly...
1041 - math_outputhash varbinary(16) NOT NULL,
1042 -
1043 - -- texvc reports how well it thinks the HTML conversion worked;
1044 - -- if it's a low level the PNG rendering may be preferred.
1045 - math_html_conservativeness tinyint NOT NULL,
1046 -
1047 - -- HTML output from texvc, if any
1048 - math_html text,
1049 -
1050 - -- MathML output from texvc, if any
1051 - math_mathml text
1052 -) /*$wgDBTableOptions*/;
1053 -
1054 -CREATE UNIQUE INDEX /*i*/math_inputhash ON /*_*/math (math_inputhash);
1055 -
1056 -
10571036 -- When using the default MySQL search backend, page titles
10581037 -- and text are munged to strip markup, do Unicode case folding,
10591038 -- and prepare the result for MySQL's fulltext index.
Index: trunk/phase3/tests/parser/parserTest.inc
@@ -707,7 +707,7 @@
708708 'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
709709 'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
710710 'site_stats', 'hitcounter', 'ipblocks', 'image', 'oldimage',
711 - 'recentchanges', 'watchlist', 'math', 'interwiki', 'logging',
 711+ 'recentchanges', 'watchlist', 'interwiki', 'logging',
712712 'querycache', 'objectcache', 'job', 'l10n_cache', 'redirect', 'querycachetwo',
713713 'archive', 'user_groups', 'page_props', 'category', 'msg_resource', 'msg_resource_links'
714714 );
Index: trunk/extensions/Math/Math.php
@@ -87,6 +87,8 @@
8888 $wgExtensionFunctions[] = 'MathHooks::setup';
8989 $wgHooks['ParserFirstCallInit'][] = 'MathHooks::onParserFirstCallInit';
9090 $wgHooks['GetPreferences'][] = 'MathHooks::onGetPreferences';
 91+$wgHooks['LoadExtensionSchemaUpdates'][] = 'MathHooks::onLoadExtensionSchemaUpdates';
 92+$wgHooks['ParserTestTables'][] = 'MathHooks::onParserTestTables';
9193
9294 $dir = dirname( __FILE__ ) . '/';
9395 $wgAutoloadClasses['MathHooks'] = $dir . 'Math.hooks.php';
Index: trunk/extensions/Math/Math.hooks.php
@@ -97,4 +97,44 @@
9898
9999 return true;
100100 }
 101+
 102+ /**
 103+ * LoadExtensionSchemaUpdates handler; set up math table on install/upgrade.
 104+ *
 105+ * @param $updater DatabaseUpdater
 106+ * @return bool
 107+ */
 108+ static function onLoadExtensionSchemaUpdates( $updater ) {
 109+ $map = array(
 110+ 'mysql' => 'math.sql',
 111+ 'sqlite' => 'math.sql',
 112+ 'postgres' => 'math.pg.sql',
 113+ 'oracle' => 'math.oracle.sql',
 114+ 'mssql' => 'math.mssql.sql',
 115+ 'db2' => 'math.db2.sql',
 116+ );
 117+ $base = dirname( __FILE__ );
 118+ $type = $updater->getDB()->getType();
 119+ if ( array_key_exists( $type, $map ) ) {
 120+ $file = $map[$type];
 121+ $sql = "$base/db/$file";
 122+ $updater->addNewExtension( 'CodeReview', $sql );
 123+ $updater->addExtensionTable( 'math', $sql );
 124+ } else {
 125+ throw new MWException( "Math extension does not currently support $type database." );
 126+ }
 127+ return true;
 128+ }
 129+
 130+ /**
 131+ * Add 'math' table to the list of tables that need to be copied to
 132+ * temporary tables for parser tests to run.
 133+ *
 134+ * @param array $tables
 135+ * @return bool
 136+ */
 137+ function onParserTestTables( &$tables ) {
 138+ $tables[] = 'math';
 139+ return true;
 140+ }
101141 }
Index: trunk/extensions/Math/db/math.mssql.sql
@@ -0,0 +1,11 @@
 2+--
 3+-- Used by the math module to keep track
 4+-- of previously-rendered items.
 5+--
 6+CREATE TABLE /*$wgDBprefix*/math (
 7+ math_inputhash varbinary(16) NOT NULL PRIMARY KEY,
 8+ math_outputhash varbinary(16) NOT NULL,
 9+ math_html_conservativeness tinyint NOT NULL,
 10+ math_html NVARCHAR(MAX),
 11+ math_mathml NVARCHAR(MAX),
 12+);
Index: trunk/extensions/Math/db/math.sql
@@ -0,0 +1,23 @@
 2+--
 3+-- Used by the math module to keep track
 4+-- of previously-rendered items.
 5+--
 6+CREATE TABLE /*_*/math (
 7+ -- Binary MD5 hash of the latex fragment, used as an identifier key.
 8+ math_inputhash varbinary(16) NOT NULL,
 9+
 10+ -- Not sure what this is, exactly...
 11+ math_outputhash varbinary(16) NOT NULL,
 12+
 13+ -- texvc reports how well it thinks the HTML conversion worked;
 14+ -- if it's a low level the PNG rendering may be preferred.
 15+ math_html_conservativeness tinyint NOT NULL,
 16+
 17+ -- HTML output from texvc, if any
 18+ math_html text,
 19+
 20+ -- MathML output from texvc, if any
 21+ math_mathml text
 22+) /*$wgDBTableOptions*/;
 23+
 24+CREATE UNIQUE INDEX /*i*/math_inputhash ON /*_*/math (math_inputhash);
Index: trunk/extensions/Math/db/math.oracle.sql
@@ -0,0 +1,8 @@
 2+CREATE TABLE &mw_prefix.math (
 3+ math_inputhash VARCHAR2(32) NOT NULL,
 4+ math_outputhash VARCHAR2(32) NOT NULL,
 5+ math_html_conservativeness NUMBER NOT NULL,
 6+ math_html CLOB,
 7+ math_mathml CLOB
 8+);
 9+CREATE UNIQUE INDEX &mw_prefix.math_u01 ON &mw_prefix.math (math_inputhash);
Index: trunk/extensions/Math/db/math.pg.sql
@@ -0,0 +1,7 @@
 2+CREATE TABLE math (
 3+ math_inputhash BYTEA NOT NULL UNIQUE,
 4+ math_outputhash BYTEA NOT NULL,
 5+ math_html_conservativeness SMALLINT NOT NULL,
 6+ math_html TEXT,
 7+ math_mathml TEXT
 8+);
Index: trunk/extensions/Math/db/math.db2.sql
@@ -0,0 +1,7 @@
 2+CREATE TABLE math (
 3+ math_inputhash VARCHAR(16) FOR BIT DATA NOT NULL UNIQUE,
 4+ math_outputhash VARCHAR(16) FOR BIT DATA NOT NULL,
 5+ math_html_conservativeness SMALLINT NOT NULL,
 6+ math_html CLOB(64K) INLINE LENGTH 4096,
 7+ math_mathml CLOB(64K) INLINE LENGTH 4096
 8+);

Follow-up revisions

RevisionCommit summaryAuthorDate
r89660Get rid of addNewExtension()/getNewExtensions() method of adding new extensio...demon17:33, 7 June 2011
r89818Fix for r86741 which broke PG update due to the math table disappearingtstarling08:03, 10 June 2011

Status & tagging log