5use InvalidArgumentException;
6use UnexpectedValueException;
60 if ( preg_match(
'!^(.+)\.(\d+)/(\d+)$!', $position, $m ) ) {
61 $this->binLog = $m[1];
62 $this->logPos = [ self::CORD_INDEX => (int)$m[2], self::CORD_EVENT => (
int)$m[3] ];
65 $gtids = array_filter( array_map(
'trim', explode(
',', $position ) ) );
66 foreach (
$gtids as $gtid ) {
69 throw new InvalidArgumentException(
"Invalid GTID '$gtid'." );
72 list( $domain, $pos ) = $components;
73 if ( isset( $this->gtids[$domain] ) ) {
78 if ( $pos > $otherPos ) {
79 $this->gtids[$domain] = $gtid;
82 $this->gtids[$domain] = $gtid;
85 if ( is_int( $domain ) ) {
91 if ( !$this->gtids ) {
92 throw new InvalidArgumentException(
"GTID set cannot be empty." );
104 if ( !( $pos instanceof
self ) ) {
105 throw new InvalidArgumentException(
"Position not an instance of " . __CLASS__ );
110 $thatPosByDomain = $pos->getActiveGtidCoordinates();
111 if ( $thisPosByDomain && $thatPosByDomain ) {
114 foreach ( $thatPosByDomain as $domain => $thatPos ) {
115 if ( isset( $thisPosByDomain[$domain] ) ) {
116 $comparisons[] = ( $thatPos <= $thisPosByDomain[$domain] );
123 return ( $comparisons && !in_array(
false, $comparisons,
true ) );
128 $thatBinPos = $pos->getBinlogCoordinates();
129 if ( $thisBinPos && $thatBinPos && $thisBinPos[
'binlog'] === $thatBinPos[
'binlog'] ) {
130 return ( $thisBinPos[
'pos'] >= $thatBinPos[
'pos'] );
138 if ( !( $pos instanceof
self ) ) {
139 throw new InvalidArgumentException(
"Position not an instance of " . __CLASS__ );
144 $thatPosDomains = array_keys( $pos->getActiveGtidCoordinates() );
145 if ( $thisPosDomains && $thatPosDomains ) {
150 return array_intersect( $thatPosDomains, $thisPosDomains ) ?
true :
false;
155 $thatBinPos = $pos->getBinlogCoordinates();
157 return ( $thisBinPos && $thatBinPos && $thisBinPos[
'binlog'] === $thatBinPos[
'binlog'] );
181 return $this->gtids ? null :
"{$this->binLog}.{$this->logPos[self::CORD_INDEX]}";
197 $this->activeDomain = (int)$id;
205 $this->activeServerId = (int)$id;
213 $this->activeServerUUID = $id;
236 foreach ( $this->gtids as $domain => $gtid ) {
241 if ( $this->
style === self::GTID_MARIA && $this->activeDomain !==
null ) {
245 if ( $this->
style === self::GTID_MARIA && $this->activeServerId !==
null ) {
247 } elseif ( $this->
style === self::GTID_MYSQL && $this->activeServerUUID !==
null ) {
252 $gtidInfos[$domain] = $pos;
265 if ( preg_match(
'!^(\d+)-(\d+)-(\d+)$!', $id, $m ) ) {
267 return [ (int)$m[1], (
int)$m[3], (int)$m[2] ];
268 } elseif ( preg_match(
'!^(\w{8}-\w{4}-\w{4}-\w{4}-\w{12}):(?:\d+-|)(\d+)$!', $id, $m ) ) {
273 return [ $m[1], (int)$m[2], $m[1] ];
285 return ( $this->binLog !==
null && $this->logPos !==
null )
293 'activeDomain' => $this->activeDomain,
294 'activeServerId' => $this->activeServerId,
295 'activeServerUUID' => $this->activeServerUUID,
302 if ( !is_array( $data ) ) {
303 throw new UnexpectedValueException( __METHOD__ .
": cannot unserialize position" );
306 $this->
init( $data[
'position'], $data[
'asOfTime'] );
307 if ( isset( $data[
'activeDomain'] ) ) {
310 if ( isset( $data[
'activeServerId'] ) ) {
313 if ( isset( $data[
'activeServerUUID'] ) ) {
323 ? implode(
',', $this->gtids )
324 : $this->
getLogFile() .
"/{$this->logPos[self::CORD_EVENT]}";
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
foreach( $res as $row) $serialized