Viewing File: /home/omtekel/www/wp-content/upgrade/backup/Linter.tar
includes/HtmlTags.php 0000666 00000005155 15133500302 0010610 0 ustar 00 <?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace MediaWiki\Linter;
class HtmlTags {
/**
* @var array
*/
private static $allowedHtmlTags;
/**
* @param SpecialLintErrors|LintErrorsPager $parent
*/
public function __construct( $parent ) {
// reuse the allowed html tags array once constructed
if ( !isset( self::$allowedHtmlTags ) ) {
$tagOptionAll = $parent->msg( 'linter-form-tag-option-all' )->escaped();
self::$allowedHtmlTags = $this->createAllowedHTMLTags();
// prepend the translatable word for 'all' to the associative array
self::$allowedHtmlTags = array_merge( [ $tagOptionAll => 'all' ], self::$allowedHtmlTags );
}
}
/**
* Create an associative array out of all valid and deprecated HTML tags
* @return array
*/
private function createAllowedHTMLTags(): array {
$allowedHtmlTags = [
'a',
'abbr',
'b', 'bdi', 'bdo', 'big', 'blockquote', 'br',
'caption', 'center', 'cite', 'code',
'data', 'dd', 'del', 'dfn', 'div', 'dl', 'dt',
'em',
'font',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr',
'i', 'ins',
'kbd',
'li',
'mark',
'ol',
'p', 'pre',
'q',
'rb', 'rp', 'rt', 'rtc', 'ruby',
's', 'samp', 'small', 'span', 'strike', 'strong', 'sub', 'sup',
'table', 'td', 'th', 'time', 'tr', 'tt',
'u', 'ul',
'var',
'wbr',
];
// create an associative array where allowed tags are set as both keys and values used
// to create UI drop down list in SpecialLintErrors.php and for user search URL string
// tag validation for a SQL query in the LinterErrorsPager.php code.
return array_combine( $allowedHtmlTags, $allowedHtmlTags );
}
/**
* @return array
*/
public function getAllowedHTMLTags(): array {
return self::$allowedHtmlTags;
}
/**
* @param string $tag
* @return bool
*/
public function checkAllowedHTMLTags( string $tag ): bool {
return in_array( $tag, self::$allowedHtmlTags, true );
}
}
maintenance/migrateTagTemplate.php 0000666 00000004531 15133500302 0013316 0 ustar 00 <?php
/**
* Maintenance script that migrates the linter_params field value to the new tag and template fields
* note: This should be run once the tag and template write functionality in linter
* recordLintJob has been enabled by setting LinterWriteTagAndTemplateColumnsStage true.
*/
use MediaWiki\Linter\Database;
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
$IP = __DIR__ . '/../../..';
}
require_once "$IP/maintenance/Maintenance.php";
class MigrateTagTemplate extends LoggedUpdateMaintenance {
/**
* @inheritDoc
*/
public function __construct() {
parent::__construct();
$this->requireExtension( 'Linter' );
$this->addDescription(
'Copy the tag and template data from the params field in the linter table'
);
$this->addOption(
'sleep',
'Sleep time (in seconds) between every batch. Default: 1 seconds',
false,
true
);
$this->setBatchSize( 1000 );
}
/**
* The Linter migrate linter_params to linter_tag and linter_template script can take a day to run on --wiki enwiki
* @inheritDoc
*/
protected function doDBUpdates() {
$config = $this->getConfig();
$enableMigrateTagAndTemplateStage = $config->get( 'LinterWriteTagAndTemplateColumnsStage' );
if ( !$enableMigrateTagAndTemplateStage ) {
$this->output( "LinterWriteTagAndTemplateColumnsStage config value is false, code disabled\n" );
return false;
}
$this->output( "Running linter migrate linter_params to tag and template function, this may take a while\n" );
$batchSize = $this->getBatchSize();
$sleep = (int)$this->getOption( 'sleep', 1 );
$dbw = self::getDB( DB_PRIMARY );
if ( !$dbw->fieldExists( 'linter', 'linter_template', __METHOD__ ) ) {
$this->output( "Run update.php to add linter_tag and linter_template fields to the linter table.\n" );
return false;
}
$this->output( "Migrating the linter_params field to the linter_tag and linter_template fields...\n" );
$updated = Database::migrateTemplateAndTagInfo( $batchSize, $sleep, false );
$this->output(
"Completed migration of linter_params data in the linter table, $updated rows updated.\n"
);
return true;
}
/**
* @inheritDoc
*/
protected function getUpdateKey() {
return 'migrate linter table linter_params data to the linter_tag and linter_template fields';
}
}
$maintClass = MigrateTagTemplate::class;
require_once RUN_MAINTENANCE_IF_MAIN;
sql/patch-linter-fix-params-null-definition.sql 0000666 00000000521 15133500302 0015613 0 ustar 00 -- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
ALTER TABLE /*_*/linter
CHANGE linter_params linter_params BLOB NOT NULL; sql/patch-linter-template-tag-fields.sql 0000666 00000001035 15133500302 0014277 0 ustar 00 -- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-add-template-tag-fields.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
ALTER TABLE /*_*/linter
ADD linter_template VARBINARY(255) DEFAULT '' NOT NULL,
ADD linter_tag VARBINARY(32) DEFAULT '' NOT NULL;
CREATE INDEX linter_cat_template ON /*_*/linter (linter_cat, linter_template);
CREATE INDEX linter_cat_tag ON /*_*/linter (linter_cat, linter_tag); sql/postgres/patch-linter-fix-params-null-definition.sql 0000666 00000000474 15133500302 0017470 0 ustar 00 -- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
ALTER TABLE linter ALTER linter_params
SET NOT NULL; sql/postgres/patch-linter-template-tag-fields.sql 0000666 00000001015 15133500302 0016143 0 ustar 00 -- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-add-template-tag-fields.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
ALTER TABLE linter
ADD linter_template TEXT DEFAULT '' NOT NULL;
ALTER TABLE linter
ADD linter_tag TEXT DEFAULT '' NOT NULL;
CREATE INDEX linter_cat_template ON linter (linter_cat, linter_template);
CREATE INDEX linter_cat_tag ON linter (linter_cat, linter_tag); sql/abstractSchemaChanges/patch-linter-fix-params-null-definition.json 0000666 00000011501 15133500302 0022202 0 ustar 00 {
"comment": "Fix linter table linter_params definition to not be nullable (T327806)",
"before": {
"name": "linter",
"columns": [
{
"name": "linter_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "autoincrement": true }
},
{
"name": "linter_page",
"comment": "page id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_namespace",
"comment": "page namespace",
"type": "integer",
"options": { "notnull": false, "unsigned": false }
},
{
"name": "linter_cat",
"comment": "error category (see CategoryManager::$categoryIds)",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_start",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_end",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_params",
"comment": "extra parameters about the error, JSON encoded",
"type": "blob",
"options": { "length": 65530, "notnull": false }
},
{
"name": "linter_template",
"comment": "name of a template if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 255, "default": "" }
},
{
"name": "linter_tag",
"comment": "name of tag if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 32, "default": "" }
}
],
"indexes": [
{
"name": "linter_page",
"comment": "Query by page",
"columns": [ "linter_page" ],
"unique": false
},
{
"name": "linter_cat_namespace",
"comment": "Query by category and namespace",
"columns": [ "linter_cat", "linter_namespace" ],
"unique": false
},
{
"name": "linter_cat_page_position",
"comment": "Unique index for lint errors, also covers linter_cat for query by category",
"columns": [ "linter_cat", "linter_page", "linter_start", "linter_end" ],
"unique": true
},
{
"name": "linter_cat_template",
"comment": "Query by template",
"columns": [ "linter_cat", "linter_template" ],
"unique": false
},
{
"name": "linter_cat_tag",
"comment": "Query by tag",
"columns": [ "linter_cat", "linter_tag" ],
"unique": false
}
],
"pk": [ "linter_id" ]
},
"after": {
"name": "linter",
"columns": [
{
"name": "linter_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "autoincrement": true }
},
{
"name": "linter_page",
"comment": "page id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_namespace",
"comment": "page namespace",
"type": "integer",
"options": { "notnull": false, "unsigned": false }
},
{
"name": "linter_cat",
"comment": "error category (see CategoryManager::$categoryIds)",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_start",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_end",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_params",
"comment": "extra parameters about the error, JSON encoded",
"type": "blob",
"options": { "length": 65530, "notnull": true }
},
{
"name": "linter_template",
"comment": "name of a template if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 255, "default": "" }
},
{
"name": "linter_tag",
"comment": "name of tag if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 32, "default": "" }
}
],
"indexes": [
{
"name": "linter_page",
"comment": "Query by page",
"columns": [ "linter_page" ],
"unique": false
},
{
"name": "linter_cat_namespace",
"comment": "Query by category and namespace",
"columns": [ "linter_cat", "linter_namespace" ],
"unique": false
},
{
"name": "linter_cat_page_position",
"comment": "Unique index for lint errors, also covers linter_cat for query by category",
"columns": [ "linter_cat", "linter_page", "linter_start", "linter_end" ],
"unique": true
},
{
"name": "linter_cat_template",
"comment": "Query by template",
"columns": [ "linter_cat", "linter_template" ],
"unique": false
},
{
"name": "linter_cat_tag",
"comment": "Query by tag",
"columns": [ "linter_cat", "linter_tag" ],
"unique": false
}
],
"pk": [ "linter_id" ]
}
}
sql/abstractSchemaChanges/patch-linter-add-template-tag-fields.json 0000666 00000010230 15133500303 0021412 0 ustar 00 {
"comment": "Filter errors by details (T175177)",
"before": {
"name": "linter",
"columns": [
{
"name": "linter_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "autoincrement": true }
},
{
"name": "linter_page",
"comment": "page id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_namespace",
"comment": "page namespace",
"type": "integer",
"options": { "notnull": false, "unsigned": false }
},
{
"name": "linter_cat",
"comment": "error category (see CategoryManager::$categoryIds)",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_start",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_end",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_params",
"comment": "extra parameters about the error, JSON encoded",
"type": "blob",
"options": { "length": 65530, "notnull": false }
}
],
"indexes": [
{
"name": "linter_page",
"comment": "Query by page",
"columns": [ "linter_page" ],
"unique": false
},
{
"name": "linter_cat_namespace",
"comment": "Query by category and namespace",
"columns": [ "linter_cat", "linter_namespace" ],
"unique": false
},
{
"name": "linter_cat_page_position",
"comment": "Unique index for lint errors, also covers linter_cat for query by category",
"columns": [ "linter_cat", "linter_page", "linter_start", "linter_end" ],
"unique": true
}
],
"pk": [ "linter_id" ]
},
"after": {
"name": "linter",
"columns": [
{
"name": "linter_id",
"type": "integer",
"options": { "notnull": true, "unsigned": true, "autoincrement": true }
},
{
"name": "linter_page",
"comment": "page id",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_namespace",
"comment": "page namespace",
"type": "integer",
"options": { "notnull": false, "unsigned": false }
},
{
"name": "linter_cat",
"comment": "error category (see CategoryManager::$categoryIds)",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_start",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_end",
"comment": "end positions of where the error is located",
"type": "integer",
"options": { "notnull": true, "unsigned": true }
},
{
"name": "linter_params",
"comment": "extra parameters about the error, JSON encoded",
"type": "blob",
"options": { "length": 65530, "notnull": false }
},
{
"name": "linter_template",
"comment": "name of a template if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 255, "default": "" }
},
{
"name": "linter_tag",
"comment": "name of tag if used or empty",
"type": "binary",
"options": { "notnull": true, "length": 32, "default": "" }
}
],
"indexes": [
{
"name": "linter_page",
"comment": "Query by page",
"columns": [ "linter_page" ],
"unique": false
},
{
"name": "linter_cat_namespace",
"comment": "Query by category and namespace",
"columns": [ "linter_cat", "linter_namespace" ],
"unique": false
},
{
"name": "linter_cat_page_position",
"comment": "Unique index for lint errors, also covers linter_cat for query by category",
"columns": [ "linter_cat", "linter_page", "linter_start", "linter_end" ],
"unique": true
},
{
"name": "linter_cat_template",
"comment": "Query by template",
"columns": [ "linter_cat", "linter_template" ],
"unique": false
},
{
"name": "linter_cat_tag",
"comment": "Query by tag",
"columns": [ "linter_cat", "linter_tag" ],
"unique": false
}
],
"pk": [ "linter_id" ]
}
}
sql/sqlite/patch-linter-template-tag-fields.sql 0000666 00000003221 15133500303 0015600 0 ustar 00 -- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-add-template-tag-fields.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
DROP INDEX linter_page;
DROP INDEX linter_cat_namespace;
DROP INDEX linter_cat_page_position;
CREATE TEMPORARY TABLE /*_*/__temp__linter AS
SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params
FROM /*_*/linter;
DROP TABLE /*_*/linter;
CREATE TABLE /*_*/linter ( linter_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, linter_page INTEGER UNSIGNED NOT NULL, linter_namespace INTEGER DEFAULT NULL, linter_cat INTEGER UNSIGNED NOT NULL, linter_start INTEGER UNSIGNED NOT NULL, linter_end INTEGER UNSIGNED NOT NULL, linter_params BLOB DEFAULT NULL, linter_template BLOB DEFAULT '' NOT NULL, linter_tag BLOB DEFAULT '' NOT NULL );
INSERT INTO /*_*/linter ( linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params )
SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params
FROM /*_*/__temp__linter;
DROP TABLE /*_*/__temp__linter;
CREATE INDEX linter_page ON /*_*/linter (linter_page);
CREATE INDEX linter_cat_namespace ON /*_*/linter (linter_cat, linter_namespace);
CREATE UNIQUE INDEX linter_cat_page_position ON /*_*/linter ( linter_cat, linter_page, linter_start, linter_end );
CREATE INDEX linter_cat_template ON /*_*/linter (linter_cat, linter_template);
CREATE INDEX linter_cat_tag ON /*_*/linter (linter_cat, linter_tag); sql/sqlite/patch-linter-fix-params-null-definition.sql 0000666 00000003215 15133500303 0017120 0 ustar 00 -- This file is automatically generated using maintenance/generateSchemaChangeSql.php.
-- Source: abstractSchemaChanges/patch-linter-fix-params-null-definition.json
-- Do not modify this file directly.
-- See https://www.mediawiki.org/wiki/Manual:Schema_changes
CREATE TEMPORARY TABLE /*_*/__temp__linter AS
SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag
FROM /*_*/linter;
DROP TABLE /*_*/linter;
CREATE TABLE /*_*/linter ( linter_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, linter_page INTEGER UNSIGNED NOT NULL, linter_namespace INTEGER DEFAULT NULL, linter_cat INTEGER UNSIGNED NOT NULL, linter_start INTEGER UNSIGNED NOT NULL, linter_end INTEGER UNSIGNED NOT NULL, linter_params BLOB NOT NULL, linter_template BLOB DEFAULT '' NOT NULL, linter_tag BLOB DEFAULT '' NOT NULL );
INSERT INTO /*_*/linter ( linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag )
SELECT linter_id, linter_page, linter_namespace, linter_cat, linter_start, linter_end, linter_params, linter_template, linter_tag
FROM /*_*/__temp__linter;
DROP TABLE /*_*/__temp__linter;
CREATE INDEX linter_page ON /*_*/linter (linter_page);
CREATE INDEX linter_cat_namespace ON /*_*/linter (linter_cat, linter_namespace);
CREATE UNIQUE INDEX linter_cat_page_position ON /*_*/linter ( linter_cat, linter_page, linter_start, linter_end );
CREATE INDEX linter_cat_template ON /*_*/linter (linter_cat, linter_template);
CREATE INDEX linter_cat_tag ON /*_*/linter (linter_cat, linter_tag);
Back to Directory
File Manager