mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-15 03:34:10 +00:00
670f0bb8f9
The motivation for this patch is to make the code less complex, better readable, and less brittle. Example: public function onExampleHook( Parser &$parser, array &$result ) { /* This is the hook handler */ } In this example the $result array is meant to be manipulated by the hook handler. Changes should become visible to the caller. Since PHP passes arrays by value, the & is needed to make this possible. But the & is misplaced in pretty much all cases where the parameter is an object. The only reason we still see these & in many hook handlers is historical: PHP 4 passed objects by value, which potentially caused expensive cloning. This was prevented with the &. Since PHP 5 objects are passed by reference. However, this did not made the & entirely meaningless. Keeping the & means callees are allowed to replace passed objects with new ones. The & makes it look like a function might intentionally replace a passed object, which is unintended and actually scary in cases like the Parser. Luckily all Hooks::run I have seen so far ignore unintended out-values. So even if a hook handler tries to do something bad like replacing the Parser with a different one, this would not have an effect. Removing the & does not remove the possibility to manipulate the object. Changes done to public properties are still visible to the caller. Unfortunately these & cannot be removed from the callers as long as there is a single callee expecting a reference. This patch reduces the number of such problematic callees. Change-Id: I21d53c989ea487607dc69e6b3365c023ef6729f5 |
||
---|---|---|
db | ||
i18n | ||
images | ||
maintenance | ||
math | ||
mathoid | ||
modules | ||
src | ||
tests | ||
texvccheck | ||
.eslintrc.json | ||
.gitattributes | ||
.gitignore | ||
.gitreview | ||
.phpcs.xml | ||
.rubocop.yml | ||
.stylelintrc.json | ||
CODE_OF_CONDUCT.md | ||
composer.json | ||
COPYING | ||
extension.json | ||
Gemfile | ||
Gemfile.lock | ||
Gruntfile.js | ||
HISTORY | ||
Makefile | ||
Math.alias.noTranslate.php | ||
Math.alias.php | ||
Math.php | ||
MathInputCheckTexvc.php | ||
MathLaTeXML.php | ||
MathTexvc.php | ||
package.json | ||
Rakefile | ||
README | ||
RELEASE-NOTES-3.0.0 |
This version (for MediaWiki 1.31) has some changes since previous versions: By default the math rendering service from the Wikimedia Foundation located at https://wikimedia.org/api/rest_v1/ will be used for math rendering. Therefore php-curl is required. cf. https://www.mediawiki.org/wiki/Manual:CURL Consult https://www.mediawiki.org/wiki/Extension:Math for further information and advanced settings. Attributes of the <math /> element: attribute "display": possible values: "inline", "block" or "inline-displaystyle" (default) "display" reproduces the old texvc behavior: The equation is rendered with large height operands (texvc used $$ $tex $$ to render) but the equation printed to the current line of the output and not centered in a new line. In Wikipedia users use :<math>$tex</math> to move the math element closer to the center. "inline" renders the equation in with small height operands by adding {\textstyle $tex } to the users input ($tex). The equation is displayed in the current text line. "inline-displaystyle" renders the equation in with large height operands centered in a new line by adding {\displaystyle $tex } to the user input ($tex). For testing your installation run php tests/phpunit/phpunit.php extensions/Math/tests/ from your MediWiki home path. == Logging == The math extension supports PSR-3 logging: Configuration can be dona via $wgDebugLogGroups['Math'] = [ 'level' => 'info', 'destination' => '/path/to/file.log' ];