Author: gero.scholz
Description:
if an extension tries to clone the MW parser, MW wants to merge LinkHolderArrays.
This leads to a php error because the cloning command (something like "$myParser = clone $parser;") oviously does not call the constructor of the LinkHolderArray. The reason is probably that the LinkHolderArray in general is only constructed on demand.
The following bugfix works, but maybe a better solution can be found:
<pre>
/**
- Merge another LinkHolderArray into this one
*/
function merge( $other ) {
// add this!! // protect against uninitialized instance (which can happen if parser is 'cloned') if (!isset($this->interwikis)) { $this->internals = array(); $this->interwikis = array(); $this->size = 0; $this->parent = $other->parent; } // end !! foreach ( $other->internals as $ns => $entries ) { $this->size += count( $entries ); if ( !isset( $this->internals[$ns] ) ) { $this->internals[$ns] = $entries; } else { $this->internals[$ns] += $entries; } } $this->interwikis += $other->interwikis;
}
</pre>
Version: 1.15.x
Severity: normal