mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-27120 Add global cache to backup_xml_transformer::register_link_encoders()
This commit is contained in:
parent
631764ea2f
commit
d729ef29cf
1 changed files with 12 additions and 1 deletions
|
@ -32,6 +32,12 @@ defined('MOODLE_INTERNAL') || die();
|
|||
*
|
||||
* TODO: Finish phpdocs
|
||||
*/
|
||||
|
||||
// cache for storing link encoders, so that we don't need to call
|
||||
// register_link_encoders each time backup_xml_transformer is constructed
|
||||
global $LINKS_ENCODERS_CACHE;
|
||||
$LINKS_ENCODERS_CACHE = array();
|
||||
|
||||
class backup_xml_transformer extends xml_contenttransformer {
|
||||
|
||||
private $absolute_links_encoders; // array of static methods to be called in order to
|
||||
|
@ -41,13 +47,18 @@ class backup_xml_transformer extends xml_contenttransformer {
|
|||
private $unicoderegexp; // to know if the site supports unicode regexp
|
||||
|
||||
public function __construct($courseid) {
|
||||
global $LINKS_ENCODERS_CACHE;
|
||||
|
||||
$this->absolute_links_encoders = array();
|
||||
$this->courseid = $courseid;
|
||||
// Check if we support unicode modifiers in regular expressions
|
||||
$this->unicoderegexp = @preg_match('/\pL/u', 'a'); // This will fail silently, returning false,
|
||||
// if regexp libraries don't support unicode
|
||||
// Register all the available content link encoders
|
||||
$this->absolute_links_encoders = $this->register_link_encoders();
|
||||
if (!empty($LINKS_ENCODERS_CACHE)) {
|
||||
$LINKS_ENCODERS_CACHE = $this->register_link_encoders();
|
||||
}
|
||||
$this->absolute_links_encoders = $LINKS_ENCODERS_CACHE;
|
||||
}
|
||||
|
||||
public function process($content) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue