mwstake/mediawiki-component-dynamicconfig 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mwstake/mediawiki-component-dynamicconfig

Composer 安装命令:

composer require mwstake/mediawiki-component-dynamicconfig

包简介

Dynamic config manager

README 文档

README

This component is designed to store configuration variables in Database and load (and apply) them from there. It is primarely meant to replace config directory in BlueSpiceFoundation and configs stored in actual static PHP files. It can be used to store any number of configurations, basically everything that goes into LocalSettings.php, except for core configs, like DB connection and similar.

Compatibility

  • 2.0.x -> MediaWiki 1.43
  • 1.0.x -> MediaWiki 1.39

Registering configs

  • Implement a class that implements MWStake\MediaWiki\Component\DynamicConfig\IDynamicConfig interface.
  • Use MWStakeDynamicConfigRegisterConfigs Hook to register your configs.

In case your config sets/reads MW globals ($GLOBALS), make it implement MWStake\MediaWiki\Component\DynamicConfig\GlobalsAwareDynamicConfig interface as well.

Using configs

To store config to DB, use

    $manager = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStakeDynamicConfigManager' );
    $manager->storeConfig( $config, $dataToBePassedToTheConfig );

This will call serialize method on the IDynamicConfig object with $dataToBePassedToTheConfig as an argument. This method must return a string to be stored to the Database.

If your config's shouldAutoApply method returns true, the config will be auto-applied on SetupAfterCache hook. Otherwise, you can apply it manually by calling

    $manager = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStakeDynamicConfigManager' );
    $manager->applyConfig( $config );

When applying, method apply will be called on the IDynamicConfig object with the data from the Database as an argument. Config itself is responsible for parsing the data and applying it.

Backups

On every change of a config value, a backup will be made. System will create up to 5 backups, after which it will rotate, deleting the oldest one.

Restoring backups

From code

    $manager = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStakeDynamicConfigManager' );
    $manager->restoreBackup( $config, $dataTime ); // DateTime object matching the timestamp of available backup

From CLI

  # List available config types
  php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php --list-types

  # List avilable backups for a type
  php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php --list-backups --config={key}

  # Restore a backup (timestamp in YmdHis format)
  php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php --backup-timestamp=20230523104627 --config={key}

Note: This will assume component is installed in the root vendor directory. If its not, specify path to Maintenance.php, as the first argument of the script.

  # List available config types
  php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php some/path/Maintenance.php --list-types

统计信息

  • 总下载量: 2.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2023-05-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固