Jump to content

Core Platform Team/Initiative/globals/Initiative Vision

From mediawiki.org

< globals

Vision:
  • MediaWiki does not use global variables to manage state.
  •  
  •  
Stakeholder(s):
  • MediaWiki developers (core and extensions) will benefit from clearer, more testable code
  • Extension developers (in WMF and elsewhere) will have more control over the behavior of pages their extension manages.
  • Quality + test engineering may be interested since we are making code more testable by removing access to global state
  • The Performance team should be consulted to ensure the proposed changes do not introduce performance issues
Problem:
  • For historical reasons, MediaWiki uses a number of global variables to represent the execution context. Usually, these variables are not accessed directly but via a RequestContext, but they still exist, and are in fact needed by RequestContext.
  • RequestContext is a kitchen-sink, bundling access to too many parts of the system, causing spurious dependencies to be introduced across the code base.
  •  
Solution:
  • Define a clear pattern for creating a RequestContext, and providing it to the code that needs it.
  • Deprecate some parts of RequestContext to make it more lightweight
  • Similarly, provide a clear information flow to provide relevant information to code that should not have access to a full RequestContext.
  • Replace global variables with stubs that emit deprecation warnings.
Aligned Goals:
  • Improve code quality by reducing coupling
  • Improve code health by improving testability
  • Improve maintainability by modeling domain concepts clearly
Success Metrics:
  •  
  •  
  • Â