Anno Codeigniterben keszitettem egy replikacio ellenorzo vegoldalt.
Namost, amiota BLM kompatibilis lett a mysql (8.0.26 -tol {igen, minor verziovaltastol adozzunk a BLM mozgalom oltaran}) megszunt -tobbek kozott- a Seconds_Behind_Master property, igy ket -es aztan jopar- dologra sikerult rajonnom:
$secs=isset($row->Seconds_Behind_Master)?$row->Seconds_Behind_Master:$row->Seconds_Behind_Source;
eredmenye
Undefined property: stdClass::$Seconds_Behind_Source
Tehat az isset() nem alkalmas nem letezo property vizsgalatara.
Mindez persze akkor jon elo, amikor van Seconds_Behind_Master, de annak az adattipusa es erteke null - mivel a replikacio adott pillanataban all.
A Seconds_Behind_Master es a Seconds_Behind_Source felvehet integert es null -t is, emiatt mas problema is lehet.
De en okos vagyok, ezert eldontottam, hogy majd a property_exists() lesz a baratom.
Ennyire:
- As opposed with isset(), property_exists() returns true even if the property has the value null.
- Returns true if the property exists, false if it doesn't exist or null in case of an error.
Magyarul nem eleg, hogy a property -ha letezik- lehet integer, vagy null, a letezeset vizsgalo function return value is lehet null vagy boolean, null raadasul akkor ha hibara fut. Ez utobbi tagmondat a wtf/sec ertekeket surun tudja emelni :)
Rajottem arra is, hogy nem eleg, hogy ritkan nyulok PHP -hoz, de mar vagy ahhoz sem ertek, vagy valami. :D
Kinomban mindenesetre vistva rohogok az egeszen, ugyanis le kell kezelnem 3 mysql es 2 mariadb replikacios szeriat. Es mivel az adott controllerhez nem irtam exception handlert, most kenytelen leszek, minden mas meg nagyobb hulladekot jelent - ha ezt meg tudom fokozni.