Skip to content

Commit

Permalink
Fix broken CI, production fatals, security, and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Dec 12, 2023
1 parent fdfdd30 commit defb34e
Show file tree
Hide file tree
Showing 18 changed files with 1,000 additions and 4,504 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ CentralAuth:
Echo:
branch: auto
repo: auto
ManageWiki:
branch: master
repo: https://github.com/WikiForge/ManageWiki
6 changes: 3 additions & 3 deletions .github/workflows/mediawiki-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
strategy:
matrix:
include:
# Latest MediaWiki LTS - PHP 8.1
# Latest MediaWiki LTS - PHP 7.4
- mw: 'REL1_39'
php: 8.1
php-docker: 81
php: 7.4
php-docker: 74
composer-test: true
experimental: false

Expand Down
2 changes: 2 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
$cfg['directory_list'] = array_merge(
$cfg['directory_list'], [
'../../extensions/Echo',
'../../extensions/ManageWiki',
]
);

$cfg['exclude_analysis_directory_list'] = array_merge(
$cfg['exclude_analysis_directory_list'], [
'../../extensions/Echo',
'../../extensions/ManageWiki',
]
);

Expand Down
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/vendor/
9 changes: 4 additions & 5 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"extends": [
"stylelint-config-idiomatic-order",
"stylelint-config-wikimedia"
],
"ignoreFiles": [
"vendor/**"
"stylelint-config-wikimedia/support-modern",
"stylelint-config-wikimedia/mediawiki"
],
"reportNeedlessDisables": true,
"rules": {
"font-weight-notation": null,
"selector-class-pattern": null,
"selector-max-id": null,
"no-descending-specificity": null,
"declaration-no-important": null,
"unit-disallowed-list": null,
"declaration-property-unit-disallowed-list": null
}
}
12 changes: 10 additions & 2 deletions includes/CreateWiki/CreateWikiJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace WikiForge\CreateWiki\CreateWiki;

use Exception;
use ExtensionRegistry;
use Job;
use MediaWiki\MediaWikiServices;
use Title;
use User;
use WikiForge\CreateWiki\RequestWiki\WikiRequest;
use WikiForge\CreateWiki\WikiManager;
use WikiForge\ManageWiki\Helpers\ManageWikiSettings;

class CreateWikiJob extends Job {
public function __construct( Title $title, array $params ) {
Expand Down Expand Up @@ -40,8 +42,14 @@ public function run() {
"[[Special:RequestWikiQueue/{$this->params['id']}|Requested]]"
);

if ( ExtensionRegistry::getInstance()->isLoaded( 'WikiDiscover' ) && $config->get( 'WikiDiscoverUseDescriptions' ) && $config->get( 'RequestWikiUseDescriptions' ) && isset( $this->params['description'] ) ) {
$mwSettings = new \WikiForge\ManageWiki\Helpers\ManageWikiSettings( $this->params['dbname'] );
if (
ExtensionRegistry::getInstance()->isLoaded( 'ManageWiki' ) &&
ExtensionRegistry::getInstance()->isLoaded( 'WikiDiscover' ) &&
$config->get( 'WikiDiscoverUseDescriptions' ) &&
$config->get( 'RequestWikiUseDescriptions' ) &&
isset( $this->params['description'] )
) {
$mwSettings = new ManageWikiSettings( $this->params['dbname'] );

$description = $mwSettings->list()['wgWikiDiscoverDescription'] ?? '';

Expand Down
3 changes: 2 additions & 1 deletion includes/CreateWiki/SpecialCreateWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class SpecialCreateWiki extends FormSpecialPage {

/** @var Config */
private $config;

/** @var CreateWikiHookRunner */
private $hookRunner;

Expand Down Expand Up @@ -126,7 +127,7 @@ public function validateDBname( $DBname, $allData ) {
if ( $check ) {
$this->getOutput()->addHTML(
Html::warningBox(
Html::element(
Html::rawElement(
'p',
[],
$check
Expand Down
2 changes: 1 addition & 1 deletion includes/CreateWikiJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private function generateDatabaseList() {
$databaseLists = [];
$this->hookRunner->onCreateWikiJsonGenerateDatabaseList( $databaseLists );

if ( !empty( $databaseLists ) ) {
if ( $databaseLists ) {
$this->generateDatabasesJsonFile( $databaseLists );
return;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/CreateWikiRegexConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ private static function regexesFromText( $text, $start = '', $end = '', $name =
* @return string
*/
public static function regexFromArray( $regexes, $start, $end, $name = '' ) {
if ( empty( $regexes ) ) {
if ( !$regexes ) {
return '';
}

self::filterInvalidRegexes( $regexes, $name, $start, $end );

if ( !empty( $regexes ) ) {
if ( $regexes ) {
$regex = $start . implode( '|', $regexes ) . $end;

if ( StringUtils::isValidPCRERegex( $regex ) ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/RemoteWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public function unMarkExperimental() {
}

public function commit() {
if ( !empty( $this->changes ) ) {
if ( $this->changes ) {
if ( $this->newRows ) {
$this->dbw->update(
'cw_wikis',
Expand Down
22 changes: 11 additions & 11 deletions includes/RequestWiki/RequestWikiRequestViewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class RequestWikiRequestViewer {

/** @var Config */
private $config;

/** @var CreateWikiHookRunner */
private $hookRunner;

Expand Down Expand Up @@ -130,16 +131,16 @@ public function getFormDescriptor(

if ( $permissionManager->userHasRight( $userR, 'createwiki' ) && !$userR->getBlock() ) {
$visibilityOptions = [
0 => wfMessage( 'requestwikiqueue-request-label-visibility-all' )->text(),
1 => wfMessage( 'requestwikiqueue-request-label-visibility-hide' )->text(),
0 => wfMessage( 'requestwikiqueue-request-label-visibility-all' )->escaped(),
1 => wfMessage( 'requestwikiqueue-request-label-visibility-hide' )->escaped(),
];

if ( $permissionManager->userHasRight( $userR, 'delete' ) ) {
$visibilityOptions[2] = wfMessage( 'requestwikiqueue-request-label-visibility-delete' )->text();
$visibilityOptions[2] = wfMessage( 'requestwikiqueue-request-label-visibility-delete' )->escaped();
}

if ( $permissionManager->userHasRight( $userR, 'suppressrevision' ) ) {
$visibilityOptions[3] = wfMessage( 'requestwikiqueue-request-label-visibility-oversight' )->text();
$visibilityOptions[3] = wfMessage( 'requestwikiqueue-request-label-visibility-oversight' )->escaped();
}

$wm = new WikiManager( $request->dbname, $this->hookRunner );
Expand Down Expand Up @@ -176,8 +177,7 @@ public function getFormDescriptor(
'visibility' => [
'type' => 'check',
'label-message' => 'revdelete-legend',
'options' => array_flip( $visibilityOptions ),
'default' => ($request->visibility != 0) ? 1 : 0,
'default' => ( $request->visibility != 0 ) ? 1 : 0,
'cssclass' => 'createwiki-infuse',
'section' => 'review',
],
Expand All @@ -194,7 +194,7 @@ public function getFormDescriptor(
'type' => 'submit',
'default' => wfMessage( 'htmlform-submit' )->text(),
'section' => 'review',
],
],
];

if ( $wmError ) {
Expand Down Expand Up @@ -419,10 +419,10 @@ protected function submitForm(
if ( !$user->isRegistered() ) {
$out->addHTML(
Html::warningBox(
Html::element(
Html::rawElement(
'p',
[],
$this->msg( 'exception-nologin-text' )->parse()
wfMessage( 'exception-nologin-text' )->parse()
),
'mw-notify-error'
)
Expand All @@ -439,7 +439,7 @@ protected function submitForm(
if ( $err !== '' ) {
$out->addHTML(
Html::warningBox(
Html::element(
Html::rawElement(
'p',
[],
wfMessage( 'createwiki-error-' . $err )->parse()
Expand Down Expand Up @@ -478,7 +478,7 @@ protected function submitForm(
Html::element(
'p',
[],
wfMessage( 'requestwiki-edit-success' )->escaped()
wfMessage( 'requestwiki-edit-success' )->plain()
),
'mw-notify-success'
)
Expand Down
3 changes: 2 additions & 1 deletion includes/RequestWiki/SpecialRequestWiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SpecialRequestWiki extends FormSpecialPage {

/** @var Config */
private $config;

/** @var CreateWikiHookRunner */
private $hookRunner;

Expand Down Expand Up @@ -192,7 +193,7 @@ public function onSubmit( array $formData ) {
if ( $err !== '' ) {
$out->addHTML(
Html::warningBox(
Html::element(
Html::rawElement(
'p',
[],
$this->msg( 'createwiki-error-' . $err )->parse()
Expand Down
10 changes: 3 additions & 7 deletions includes/RequestWiki/WikiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function __construct( int $id = null, CreateWikiHookRunner $hookRunner =
$this->migrationtype = $dbRequest->cw_migrationtype;
$this->migrationdetails = $dbRequest->cw_migrationdetails;
$this->publicdescription = $dbRequest->cw_publicdescription;

$newDesc = explode( "\n", $dbRequest->cw_comment, 2 );
$purposeCheck = explode( ':', $newDesc[0], 2 );

Expand Down Expand Up @@ -335,7 +335,7 @@ public function save() {
'cw_migrationlocation' => $this->migrationlocation,
'cw_migrationtype' => $this->migrationtype,
'cw_migrationdetails' => $this->migrationdetails,
'cw_publicdescription' => $this->publicdescription,
'cw_publicdescription' => $this->publicdescription,
];

$this->dbw->upsert(
Expand Down Expand Up @@ -375,10 +375,6 @@ public function tryAutoCreate() {
* @return boolean true subdomain is valid and accepted, false otherwise
*/
public function parseSubdomain( string $subdomain, string &$err = '' ) {
if ( isset( $alldata['submit-comment'] ) || ( isset( $alldata['submit-handle'] ) && $alldata['submission-action'] !== 'create' ) ) {
return true;
}

$subdomain = strtolower( $subdomain );
if ( strpos( $subdomain, $this->config->get( 'CreateWikiSubdomain' ) ) !== false ) {
$subdomain = str_replace( '.' . $this->config->get( 'CreateWikiSubdomain' ), '', $subdomain );
Expand All @@ -389,12 +385,12 @@ public function parseSubdomain( string $subdomain, string &$err = '' ) {
'CreateWikiDisallowedSubdomains'
);

// Make the subdomain a dbname
$database = $subdomain . $this->config->get( 'CreateWikiDatabaseSuffix' );
if ( in_array( $database, $this->config->get( 'LocalDatabases' ) ) ) {
$err = 'subdomaintaken';

return false;
// Make the subdomain a dbname
} elseif ( !ctype_alnum( $subdomain ) ) {
$err = 'notalnum';

Expand Down
27 changes: 13 additions & 14 deletions modules/ext.createwiki.oouiform.ooui.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@
mw.hook( 'htmlform.enhance' ).fire( panel.$element );
panel.$element.data( 'mw-section-infused', true );
}
// Add <hr> to divide between the wiki approval pane and the wiki request editing pane for WCs
var targetElement = document.getElementById('ooui-php-53');

if (targetElement) {
// Create a <br> element
var brElement = document.createElement('br');
// Add <hr> to divide between the wiki approval pane and the wiki request editing pane for WCs
var targetElement = document.getElementById( 'ooui-php-53' );

// Create an <hr> element
var hrElement = document.createElement('hr');
if ( targetElement ) {
// Create a <br> element
var brElement = document.createElement( 'br' );

// Insert the <hr> element after the target element
targetElement.parentNode.insertBefore(hrElement, targetElement.nextSibling);
// Create an <hr> element
var hrElement = document.createElement( 'hr' );

// Insert the <br> element after the target element
targetElement.parentNode.insertBefore(brElement, targetElement.nextSibling);
} else {
console.error("Element with ID 'ooui-php-53' not found.");
}
// Insert the <hr> element after the target element
targetElement.parentNode.insertBefore( hrElement, targetElement.nextSibling );

// Insert the <br> element after the target element
targetElement.parentNode.insertBefore( brElement, targetElement.nextSibling );
}
}

function onTabPanelSet( panel ) {
Expand Down
Loading

0 comments on commit defb34e

Please sign in to comment.