Extension inventory

From Freephile Wiki
Revision as of 18:00, 12 September 2025 by Admin (talk | contribs) (Create some content from simple script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is just a one-off example of how we compiled a list of 'missing' extensions for Meza

Given a list of 'Bundled' extensions to MediaWiki

# This is a list of bundled extensions from 
# https://www.mediawiki.org/wiki/Bundled_extensions_and_skins
AbuseFilter
CategoryTree
CheckUser
Cite
CiteThisPage
CodeEditor
ConfirmEdit
DiscussionTools
Echo
Gadgets
ImageMap
InputBox
Linter
LoginNotify
Math
MultimediaViewer
Nuke
OATHAuth
PageImages
ParserFunctions
PdfHandler
Poem
ReplaceText
Scribunto
SecureLinkFixer
SpamBlacklist
SyntaxHighlight
TemplateData
TemplateStyles
TextExtracts
Thanks
TitleBlacklist
VisualEditor
WikiEditor

And given a Yaml file that contains a list of our own project extensions.

We generated a list of the missing ones

<?php
// Script to find extensions in bundled_extensions.txt that are NOT in MezaCoreExtensions.yml

function extractExtensionNamesFromYaml($filePath) {
    $yamlContent = file_get_contents($filePath);
    $extensions = yaml_parse($yamlContent);
    $names = [];
    if (isset($extensions['list'])) {
        foreach ($extensions['list'] as $extension) {
            if (isset($extension['name'])) {
                $names[] = $extension['name'];
            }
        }
    }
    return $names;
}

function extractExtensionNamesFromTxt($filePath) {
    $lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    $names = [];
    foreach ($lines as $line) {
        $line = trim($line);
        // Skip comments and empty lines
        if ($line === '' || strpos($line, '#') === 0) {
            continue;
        }
        $names[] = $line;
    }
    return $names;
}

// Path to files
$bundledFile = '/opt/meza/src/scripts/bundled_extensions.txt';
$coreYaml = '/opt/meza/config/MezaCoreExtensions.yml';

$bundled = extractExtensionNamesFromTxt($bundledFile);
$core = extractExtensionNamesFromYaml($coreYaml);

// Find bundled extensions not in core
$toAdd = array_diff($bundled, $core);

// Output results
if (count($toAdd) === 0) {
    echo "All bundled extensions are already in core.\n";
} else {
    echo "Extensions to add to core (" . count($toAdd) . "):\n";
    foreach ($toAdd as $name) {
        echo "- $name\n";
    }
}