mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 06:54:00 +00:00
0fe9dbb366
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: Ib3a9da257b50326d569ab1973b523c952963c16b |
||
---|---|---|
i18n | ||
includes | ||
modules | ||
tests | ||
.eslintrc.json | ||
.gitignore | ||
.gitreview | ||
.phpcs.xml | ||
.stylelintrc.json | ||
AUTHORS.txt | ||
Cite.php | ||
CODE_OF_CONDUCT.md | ||
composer.json | ||
COPYING.txt | ||
extension.json | ||
Gruntfile.js | ||
MIT-LICENSE.txt | ||
package.json | ||
README.md |
Cite
The Cite extension provides a way for users to create references as footnotes to articles.
See https://www.mediawiki.org/wiki/Extension:Cite for detailed documentation.
Configuration
$wgCiteStoreReferencesData
: If set to true, references are saved in the database so that other extensions can retrieve them independently of the main article content.$wgCiteCacheReferencesDataOnParse
: ($wgCiteStoreReferencesData
required) By default, references are cached only on database access. If set to true, references are also cached whenever pages are parsed.