1 回答

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊
好的,發(fā)生的事情是這樣的:該錯(cuò)誤僅在排序時(shí)針對(duì)某些條目觸發(fā),而不是針對(duì)全部條目。(日志中有大量此類錯(cuò)誤,因此僅從外觀上看并不明顯。)
看__get()代碼:
public function __get( $prop ) {
if ( isset( $this->$prop ) ) {
return $this->$prop;
} else {
error_log( "Call to nonexistent '$prop' property of " . __CLASS__ . " class" )
return null;
}
}
來自數(shù)據(jù)庫(kù)的一些數(shù)據(jù)具有空白字段,這對(duì)于代碼來說是空的。 isset( null )是一個(gè) false-y 值,因此elseIf 的子句在這些條目上觸發(fā)。
修復(fù)?不檢查isset(),檢查property_exists()。
public function __get( $prop ) {
if ( property_exists( $this, $prop ) ) {
...
- 1 回答
- 0 關(guān)注
- 150 瀏覽
添加回答
舉報(bào)