/** * returns a cached post object or adds existing posts to the cache * * @param int|WallTable[] $id * @return WallTable|null */ static public function getPost( $id ) { static $cache = array(); if ( is_array( $id ) ) { foreach ( $id as $row ) { /** @var WallTable $row */ $rowId = (int) $row->get( 'id' ); if ( ! $rowId ) { continue; } $cache[$rowId] = $row; } return null; } elseif ( ! $id ) { return new WallTable(); } elseif ( ! isset( $cache[$id] ) ) { $row = new WallTable(); $row->load( (int) $id ); $cache[$id] = $row; } return $cache[$id]; }