MediaWiki master
GlobalDependency.php
Go to the documentation of this file.
1<?php
8
17 private $name;
19 private $value;
20
21 public function __construct( string $name ) {
22 $this->name = $name;
23 $this->value = $GLOBALS[$name];
24 }
25
27 public function isExpired( $callback = null ) {
28 if ( !isset( $GLOBALS[$this->name] ) ) {
29 if ( is_callable( $callback ) ) {
30 $callback( "No global named {$this->name}" );
31 }
32 return true;
33 }
34
35 if ( $GLOBALS[$this->name] != $this->value ) {
36 if ( is_callable( $callback ) ) {
37 // @ silences "var_export does not handle circular references";
38 // phpcs:disable Generic.PHP.NoSilencedErrors.Discouraged
39 $old = @var_export( $this->value, true );
40 $new = @var_export( $GLOBALS[$this->name], true );
41 // phpcs:enable Generic.PHP.NoSilencedErrors.Discouraged
42 $callback( "Value of global {$this->name} changed from {$old} to {$new}" );
43 }
44 return true;
45 }
46
47 return false;
48 }
49}
Base class to represent dependencies for LocalisationCache entries.