public function getLastValidBlockItem(Block $block)
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select(
                $this->connection->quoteIdentifier('p.object_id'),
                $this->connection->quoteIdentifier('p.node_id'),
                $this->connection->quoteIdentifier('p.priority'),
                $this->connection->quoteIdentifier('p.ts_publication'),
                $this->connection->quoteIdentifier('p.ts_visible'),
                $this->connection->quoteIdentifier('p.ts_hidden'),
                $this->connection->quoteIdentifier('p.rotation_until'),
                $this->connection->quoteIdentifier('p.moved_to')
            )
            ->from($this->connection->quoteIdentifier(self::EZM_POOL_TABLE), 'p')
            ->where(
                $query->expr()->eq('p.block_id', ':blockId'),
                $query->expr()->gt('p.ts_visible', ':tsVisible'),
                $query->expr()->eq('p.ts_hidden', ':tsHidden')
            )
            ->setParameter(':blockId', $block->id)
            ->setParameter(':tsVisible', 0, PDO::PARAM_INT)
            ->setParameter(':tsHidden', 0, PDO::PARAM_INT)
            ->orderBy('p.ts_visible', 'DESC')
            ->setMaxResults(1)
        ;

        $statement = $query->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);
        if (empty($rows)) {
            return null;
        }

        return $this->buildBlockItem(
            $rows[0] + array(
                'block_id' => $block->id,
                'ts_hidden' => 0,
            )
        );
    }