From 22be1d7513d666a75be6af31ec775c16d5008781 Mon Sep 17 00:00:00 2001 From: Charlot Date: Fri, 27 Mar 2026 11:04:54 +0100 Subject: [PATCH 1/9] Version 2.8.1. mwrandom become more random --- README.md | 1 + extension.json | 2 +- src/Processors/Files/Upload.php | 2 +- src/Processors/Utilities/General.php | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index da5c1a91..9a3e427b 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ Visit this documentation page https://www.open-csp.org/DevOps:Doc/FlexForm/2.0/V Visit : https://www.open-csp.org/DevOps:Doc/FlexForm ### Changelog +* 2.8.1 : Make sure mwrandom is even more random * 2.8.0 : Pandoc conversions expanded. See online documentation * 2.7.2 : Changed submitting of Forms to a better viewable submit status. Introducing --ff-overlay-bg, --ff-spinner-base, --ff-spinner-color-1 and --ff-spinner-color-2 css variables to control colors. * 2.7.1 : Added: action=FlexFormOpen&ffAction=canUserBeCreated&additionalData=Harry (example) to check if a user can exist. Added use_mediawiki_mail_settings config setting. diff --git a/extension.json b/extension.json index ca2d02a8..5d978305 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "FlexForm", - "version": "2.8.0", + "version": "2.8.1", "author": [ "[https://www.wikibase-solutions.com/author/charlot Sen-Sai]" ], diff --git a/src/Processors/Files/Upload.php b/src/Processors/Files/Upload.php index ff3458d1..e715e843 100644 --- a/src/Processors/Files/Upload.php +++ b/src/Processors/Files/Upload.php @@ -490,7 +490,7 @@ public function fileUpload(): bool { $titleName ); } - $titleName = ContentCore::parseTitle( $titleName ); + $titleName = ContentCore::parseTitle( $titleName ) . '-' . $i; if ( Config::isDebug() ) { Debug::addToDebug( 'Title after parsetitle file #' . $i, diff --git a/src/Processors/Utilities/General.php b/src/Processors/Utilities/General.php index fc07fcbd..0cdee5a1 100644 --- a/src/Processors/Utilities/General.php +++ b/src/Processors/Utilities/General.php @@ -163,7 +163,7 @@ public static function is_cli(): bool { * @return int */ public static function MakeTitle() : int { - return time(); + return time() . mt_rand( 1,100 ); } /** From f41a7728ed081b5a4930dde4ed93e2cae9af94a5 Mon Sep 17 00:00:00 2001 From: Charlot Date: Fri, 27 Mar 2026 11:13:42 +0100 Subject: [PATCH 2/9] Version 2.8.1. mwrandom become more random. Expanded the README --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a3e427b..f4b5037f 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ $wgFlexFormConfig['secure'] = true; //( d $wgFlexFormConfig['sec_key'] = ""; // A salt key for encryption. Used together with "secure" option. Must be set when using multiple instances of a wiki $wgFlexFormConfig['auto_save_interval'] = 30000; // defaults to 3 minutes. $wgFlexFormConfig['auto_save_after_change'] = 3000; // defaults to 3 seconds after last change +$wgFlexFormConfig['auto_save_btn_on'] = 'Autosave on'; // Text on the autosave button to toggle on. +$wgFlexFormConfig['auto_save_btn_off'] = 'Autosave off';// Text on the autosave button to toggle off. $wgFlexFormConfig['FlexFormDefaultTheme'] = "Plain"; // Currently the only form $wgFlexFormConfig['rc_site_key'] = ""; // reCaptcha site key $wgFlexFormConfig['rc_secret_key'] = ""; // reCaptcha secret key @@ -46,9 +48,14 @@ $wgFlexFormConfig['renderi18nErrorInsteadofImageForApprovedForms'] = false; // W $wgFlexFormConfig['userscaneditallpages'] = false; // Defaults to false. This differs from FlexForm before 2.0. FlexForm will now honor the UserCan functions in MediaWiki. If a form edits or creates a page a user has no rights to, the form will fail. $wgFlexFormConfig['hideEdit'] = true; // Defaults to true. If a user is not in the allowedGroups then hide edit and editsource menu items for any page containing a FlexForm form. $wgFlexFormConfig['create-seo-titles'] = true; // Defaults to false. Will filter any user input on creating a new page to be SEO friendly. -$wgFlexFormConfig['auto_save_btn_on'] = "Autosave On"; -$wgFlexFormConfig['auto_save_btn_off'] = "Autosave Off"; +$wgFlexFormConfig['pandoc-install-path'] = ''; // If you want to use a different Pandoc version than the one installed on the server by default +$wgFlexFormConfig['pandoc-convert-to'][] = 'mediawiki'; // defaults to MediaWiki, but you can add more +$wgFlexFormConfig['pandoc-convert-from'][] = 'docx'; // defaults to docx, but you can add more +$wgFlexFormConfig['pandoc-allow-additional-arguments'] = ""; // add additional Pandoc arguments to a convert +$wgFlexFormConfig['forceNullEdit'] = true; // Default to true for backwards compatibility +$wgFlexFormConfig['allowFlexFormOpenAPI'] = false; // As of version 2.7.1: This will enable FlexFormOpenAPI, making it possible to use API 'CanUserBeCreated' which does not require read-rights. $wgFlexFormConfig['loadScriptPath'] = ""; // Defaults to what is described by the loadscript form argument. When you change it do a different folder, then loadScript argument will be looking in this folder for its JavaScript file to load with the Form. +$wgFlexFormConfig['use_mediawiki_mail_settings'] = false; // As of version 2.7.1: When sending email, should we use MediaWiki mail settings (defaults to false)? If set to true: when MediaWiki wgSMTP is set, FlexForm will use those settings, if they are not set, FlexForm will not use SMTP. $wgFlexFormConfig['use_smtp'] = false; // when sending email, should we use separate smtp ? $wgFlexFormConfig['smtp_host'] = ""; $wgFlexFormConfig['smtp_authentication'] = true; From dabaf3c44b386fe33c5bd799e5c2bd4218e5ded2 Mon Sep 17 00:00:00 2001 From: Charlot Date: Fri, 27 Mar 2026 11:15:17 +0100 Subject: [PATCH 3/9] Made FlexForm adminlinks parts of Open CSP --- FlexForm.hooks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FlexForm.hooks.php b/FlexForm.hooks.php index d21f7a1f..75cc4afc 100644 --- a/FlexForm.hooks.php +++ b/FlexForm.hooks.php @@ -57,14 +57,14 @@ public static function availableHooks() { */ public static function addToAdminLinks( ALTree &$adminLinksTree ) { global $wgScript; - $wsSection = $adminLinksTree->getSection( 'WikiBase Solutions' ); + $wsSection = $adminLinksTree->getSection( 'Open CSP' ); if ( is_null( $wsSection ) ) { - $section = new ALSection( 'WikiBase Solutions' ); + $section = new ALSection( 'Open CSP' ); $adminLinksTree->addSection( $section, wfMessage( 'adminlinks_general' )->text() ); - $wsSection = $adminLinksTree->getSection( 'WikiBase Solutions' ); + $wsSection = $adminLinksTree->getSection( 'Open CSP' ); $extensionsRow = new ALRow( 'extensions' ); $wsSection->addRow( $extensionsRow ); } From 39ac53b1d6d87547511c9010ffb5dc9ac8c446c1 Mon Sep 17 00:00:00 2001 From: Charlot Date: Tue, 31 Mar 2026 08:31:30 +0200 Subject: [PATCH 4/9] Added check for correct config value --- src/Processors/Files/Upload.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Processors/Files/Upload.php b/src/Processors/Files/Upload.php index e715e843..9a33cfb7 100644 --- a/src/Processors/Files/Upload.php +++ b/src/Processors/Files/Upload.php @@ -199,9 +199,17 @@ private function checkAllowedConversions( string $from, string $to, array $addit return "Convert to '$to' is not allowed."; } if ( !empty( $additional ) ) { - foreach ( $additional as $singleAdditional ) { - if ( !in_array( $singleAdditional, Config::getConfigVariable( 'pandoc-allow-additional-arguments' ) ) ) { - return "Additional argument '$singleAdditional' is not allowed."; + $pandocAllowedArguments = Config::getConfigVariable( 'pandoc-allow-additional-arguments' ); + if ( !empty( $pandocAllowedArguments ) && is_array( $pandocAllowedArguments ) ) { + foreach ( $additional as $singleAdditional ) { + if ( + !in_array( + $singleAdditional, + Config::getConfigVariable( 'pandoc-allow-additional-arguments' ) + ) + ) { + return "Additional argument '$singleAdditional' is not allowed."; + } } } } From 0608e5bc51ab7cb4253f6acbf8c481022ba38d25 Mon Sep 17 00:00:00 2001 From: Charlot Date: Tue, 31 Mar 2026 08:31:59 +0200 Subject: [PATCH 5/9] Added check for correct config value --- src/Processors/Files/Upload.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Processors/Files/Upload.php b/src/Processors/Files/Upload.php index 9a33cfb7..db5b12a6 100644 --- a/src/Processors/Files/Upload.php +++ b/src/Processors/Files/Upload.php @@ -211,6 +211,8 @@ private function checkAllowedConversions( string $from, string $to, array $addit return "Additional argument '$singleAdditional' is not allowed."; } } + } else { + return "Additional arguments not correctly set in Config"; } } From c86acafe629fb11e2fd26ad29277815009965f06 Mon Sep 17 00:00:00 2001 From: Charlot Date: Tue, 31 Mar 2026 08:48:14 +0200 Subject: [PATCH 6/9] Fix fetching Pandoc config --- src/Processors/Files/Upload.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Processors/Files/Upload.php b/src/Processors/Files/Upload.php index db5b12a6..4967dad1 100644 --- a/src/Processors/Files/Upload.php +++ b/src/Processors/Files/Upload.php @@ -198,16 +198,12 @@ private function checkAllowedConversions( string $from, string $to, array $addit if ( !in_array( $to, Config::getConfigVariable( 'pandoc-convert-to' ) ) ) { return "Convert to '$to' is not allowed."; } + if ( !empty( $additional ) ) { $pandocAllowedArguments = Config::getConfigVariable( 'pandoc-allow-additional-arguments' ); if ( !empty( $pandocAllowedArguments ) && is_array( $pandocAllowedArguments ) ) { - foreach ( $additional as $singleAdditional ) { - if ( - !in_array( - $singleAdditional, - Config::getConfigVariable( 'pandoc-allow-additional-arguments' ) - ) - ) { + foreach ( $additional as $key => $singleAdditional ) { + if ( !in_array( $key, $pandocAllowedArguments ) ) { return "Additional argument '$singleAdditional' is not allowed."; } } From bd8d06808c62b55a9d741243433aafc6abeb0dd3 Mon Sep 17 00:00:00 2001 From: Charlot Date: Tue, 31 Mar 2026 10:18:21 +0200 Subject: [PATCH 7/9] Add 0 padding to random number --- src/Processors/Utilities/General.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Processors/Utilities/General.php b/src/Processors/Utilities/General.php index 0cdee5a1..c26eae60 100644 --- a/src/Processors/Utilities/General.php +++ b/src/Processors/Utilities/General.php @@ -163,7 +163,14 @@ public static function is_cli(): bool { * @return int */ public static function MakeTitle() : int { - return time() . mt_rand( 1,100 ); + $randomExtraNumber = str_pad( + mt_rand( 1,999 ), + 3, + '0', + STR_PAD_LEFT + ); + return time() . $randomExtraNumber; + } /** From 09125204e67d0a71106cf2efeebe9321dbe3a9d1 Mon Sep 17 00:00:00 2001 From: Designburo Date: Tue, 31 Mar 2026 14:07:51 +0200 Subject: [PATCH 8/9] Only add extra number to files when needed and only for Random files --- src/Processors/Content/ContentCore.php | 27 ++++++++++++++++++++++++++ src/Processors/Files/Upload.php | 3 ++- src/Processors/Utilities/General.php | 3 ++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Processors/Content/ContentCore.php b/src/Processors/Content/ContentCore.php index 14c20c32..b155c205 100644 --- a/src/Processors/Content/ContentCore.php +++ b/src/Processors/Content/ContentCore.php @@ -56,6 +56,11 @@ class ContentCore { */ public static string $jobUser; + /** + * @var int + */ + private static int $fileNumber = 0; + /** * @return array */ @@ -63,6 +68,24 @@ public static function getFields(): array { return self::$fields; } + /** + * @param int $fCount + * + * @return void + */ + public static function setFileCount( int $fCount ): void { + self::$fileNumber = $fCount; + } + + /** + * @return int + */ + private static function getFileCount(): int { + $fCount = self::$fileNumber; + self::$fileNumber = 0; + return $fCount; + } + /** * Set userpage in Summary if not summary is available. * @@ -749,11 +772,15 @@ public static function parseTitle( string $title, bool $noSEO = false ) { } foreach ( $tmp as $fieldname ) { if ( $fieldname == 'mwrandom' ) { + $fCount = self::getFileCount(); $title = str_replace( '[' . $fieldname . ']', General::MakeTitle(), $title ); + if ( $fCount > 0 ) { + $title .= '-' . $fCount; + } } elseif ( isset( $_POST[General::makeUnderscoreFromSpace( $fieldname )] ) ) { $fn = $_POST[General::makeUnderscoreFromSpace( $fieldname )]; if ( is_array( $fn ) ) { diff --git a/src/Processors/Files/Upload.php b/src/Processors/Files/Upload.php index 4967dad1..d56f8bc0 100644 --- a/src/Processors/Files/Upload.php +++ b/src/Processors/Files/Upload.php @@ -496,7 +496,8 @@ public function fileUpload(): bool { $titleName ); } - $titleName = ContentCore::parseTitle( $titleName ) . '-' . $i; + ContentCore::setFileCount( $i ); + $titleName = ContentCore::parseTitle( $titleName ); if ( Config::isDebug() ) { Debug::addToDebug( 'Title after parsetitle file #' . $i, diff --git a/src/Processors/Utilities/General.php b/src/Processors/Utilities/General.php index c26eae60..f3cc829d 100644 --- a/src/Processors/Utilities/General.php +++ b/src/Processors/Utilities/General.php @@ -10,6 +10,7 @@ namespace FlexForm\Processors\Utilities; +use FlexForm\Processors\Content\ContentCore; use FlexForm\Processors\Security\wsSecurity; use HTMLPurifier; use HTMLPurifier_Config; @@ -162,7 +163,7 @@ public static function is_cli(): bool { /** * @return int */ - public static function MakeTitle() : int { + public static function MakeTitle(): int { $randomExtraNumber = str_pad( mt_rand( 1,999 ), 3, From 3121d1290138983e82df5518ca04a14b81d2088c Mon Sep 17 00:00:00 2001 From: Designburo Date: Tue, 31 Mar 2026 14:29:12 +0200 Subject: [PATCH 9/9] Only add extra number to files when needed and only for Random files --- src/Processors/Content/ContentCore.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Processors/Content/ContentCore.php b/src/Processors/Content/ContentCore.php index b155c205..625b41d0 100644 --- a/src/Processors/Content/ContentCore.php +++ b/src/Processors/Content/ContentCore.php @@ -773,14 +773,15 @@ public static function parseTitle( string $title, bool $noSEO = false ) { foreach ( $tmp as $fieldname ) { if ( $fieldname == 'mwrandom' ) { $fCount = self::getFileCount(); + $randomNumber = General::MakeTitle(); + if ( $fCount > 0 ) { + $randomNumber .= '-' . $fCount; + } $title = str_replace( '[' . $fieldname . ']', - General::MakeTitle(), + $randomNumber, $title ); - if ( $fCount > 0 ) { - $title .= '-' . $fCount; - } } elseif ( isset( $_POST[General::makeUnderscoreFromSpace( $fieldname )] ) ) { $fn = $_POST[General::makeUnderscoreFromSpace( $fieldname )]; if ( is_array( $fn ) ) {