Probably an undetected stupid and untested bug since release 1.23 with a huge performance impact on all systems, and extremely easy to solve.
Performance impact
- Very large Apache error.log file (100s of GB, or worse depending on the webserver traffic)
- 100% CPU per core
- Very slow application
Root cause: bad placement of regex "-" code in character range
Functionally, the application continues to run, but with a major impact on system performance (CPU and error log) and the user experience. The problem occurs during the search, editing, saving, etc. of pages...
The problem seem to exist in all versions of Mediwiki since 1.23. It is very odd that this problem has not been discovered for years...
Errors in Apache error.log
PHP Warning: preg_replace(): Compilation failed: invalid range in character class at offset 4 in includes/media/FormatMetadata.php on line 1864
Patch
It can be easily solved by moving the - just before the closing ]
rcsdiff -u includes/media/FormatMetadata.php RCS file: RCS/FormatMetadata.php,v retrieving revision 1.1 diff -u -r1.1 FormatMetadata.php --- FormatMetadata.php 2020/11/18 10:30:28 1.1 +++ FormatMetadata.php 2020/11/18 10:30:54 @@ -1877,7 +1877,7 @@ // be used so we take the easy way $key = preg_replace( '/[^a-zA-z0-9_:.\-]/', '', $key ); // drop characters which are invalid at the first position - $key = preg_replace( '/^[\d\-.]+/', '', $key ); + $key = preg_replace( '/^[\d\.-]+/', '', $key ); if ( $key == '' ) { $key = '_'; } // special case for an internal keyword - if ( $key == '_element' ) { + elif ( $key == '_element' ) { $key = 'element'; }