Php KNP Paginator在Symfony 5中显示每个页码的无效项错误

Php KNP Paginator在Symfony 5中显示每个页码的无效项错误,php,symfony,binary,uuid,paginator,Php,Symfony,Binary,Uuid,Paginator,它一直工作到今天。整个应用程序都没有bug,直到昨天我才尝试将UUID实现为二进制类型。所以我首先使用了ramsey UUID,后来尝试了一个symfony捆绑包,因为他们最近添加了它,升级了composer,安装了新的orm,最后安装了ramsey/UUID binary,我的应用程序终于开始工作了 但我一分钟一分钟地开始注意到一大堆问题。第一个是,需要在QB中的参数中添加“uuid_binary”类型。后来,当我在自己的查询中按实体搜索时,我需要的不是实体而是实体->getId() 最后,这

它一直工作到今天。整个应用程序都没有bug,直到昨天我才尝试将UUID实现为二进制类型。所以我首先使用了ramsey UUID,后来尝试了一个symfony捆绑包,因为他们最近添加了它,升级了composer,安装了新的orm,最后安装了ramsey/UUID binary,我的应用程序终于开始工作了

但我一分钟一分钟地开始注意到一大堆问题。第一个是,需要在QB中的参数中添加“uuid_binary”类型。后来,当我在自己的查询中按实体搜索时,我需要的不是实体而是实体->getId()

最后,这是一个问题,paginator崩溃了,我不知道为什么

这就是错误:

每个页码的项目无效。限制:10和页码:0,必须是正非零整数

错误在525上,这是每页的/*限制*/linie

这是矿长:

        /**
     * @Route("thread/{threadid}/{threadname}", name="app_forum_thread_user", defaults={"threadname"=""})
     * @Security("is_granted('ROLE_USER')")
     */
    public function openThread(MainMenuService $mainMenuService, PaginatorInterface $paginator,
                               UserForumPostRepository $forumPostRepo, Request $request,
                               UserForumTopic $threadid, SessionInterface $session, EntityManagerInterface $em,
                               LoggerInterface $logger, PostsLikesRepository $like){
        $referer_array = explode('/', parse_url($request->headers->get('referer'))['path']);
        if ($referer_array[1] != 'thread' and $referer_array[2] != $threadid->getId()) {
            $views = $threadid->getViews();
            $threadid->setViews($views + 1);

            $em->persist($threadid);
            $em->flush();
        }

    

    //$pagination = $forumPostRepo->findPostsMinePagination($threadid->getId(), ($request->query->get('page'))? $request->query->get('page') : 0, ($session->get('plimit')) ? $session->get('plimit') : 10);
//
    

$query = $forumPostRepo->findPostsForThreadWithPagination($threadid->getId());
        $pagination = $paginator->paginate(
            $query, /* query NOT result */
            $request->query->getInt('page', 1), /*page number*/
            ($session->get('plimit') != null) ? $session->get('plimit') : 10 /*limit per page*/
        );
        $postsLikes = [];
        foreach ($pagination as $post){
            $wynik = $like->getPostLike($post->getId(), $this->getUser()->getId());

            $postsLikes[$post->getId()] = ($wynik)? 1 : 0 ;
        }
        $mainMenu = $mainMenuService->getMenu();

        return $this->render($_SERVER['DEFAULT_TEMPLATE'].'/forum/Thread_View.twig', [
            'title'=>'Forum - '.$_SERVER['APP_NAME'],
            'lang'=>'pl',
            'APP_NAME'=>$_SERVER['APP_NAME'],
            'logoSite'=>$_SERVER['SHOW_LOGO'],
            'navFooter'=>$_SERVER['NAV_FOOTER'],
            'footer'=>$_SERVER['FOOTER'],
            'pageName'=>"Forum",
            'MainMenu' => $mainMenu,
            'user'=>$this->getUser(),
            'profile'=>$threadid->getForum()->getCategory()->getIsItUserPrivateForum()->getUserAdmin(),
            'forumCre'=>$threadid->getForum()->getCategory()->getIsItUserPrivateForum(),
            'forum'=>$threadid->getForum(),
            'thread'=>$threadid,
            'posts_pagination'=>$pagination,
            'postsLikes'=>$postsLikes,
            'page'=> $request->query->get('page'),
            'theme'=>$this->theme

        ]);
        //return new Response('done');
    }
使用语句:

use App\Entity\Account;

use App\Entity\ForumCategory;
use App\Entity\PostsLikes;
use App\Entity\UserForumCategory;
use App\Entity\UserForumForum;
use App\Entity\UserForumPost;
use App\Entity\UserForumTopic;
use App\Entity\UserPrivateForum;
use App\Repository\AccountRepository;
use App\Repository\ForumCategoryRepository;
use App\Repository\ForumForumRepository;
use App\Repository\PostsLikesRepository;
use App\Repository\UserForumCategoryRepository;
use App\Repository\UserForumForumRepository;
use App\Repository\UserForumPostRepository;
use App\Repository\UserForumTopicRepository;
use App\Repository\UserPrivateForumRepository;
use App\Services\MainMenuService;
use App\Services\Validation;
use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\PaginatorInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpCache\SubRequestHandler;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\User\UserInterface;
use Knp\Bundle\PaginatorBundle\Subscriber\SlidingPaginationSubscriber;
use Psr\Log\LoggerInterface;
正如您在控制器中看到的,我的分页器将session作为值。我试着只留下10个,但还是有错误


请帮助

您的分页器中设置为0的是
页面
而不是
plimit
,因此它看起来像是强制错误,您得到的是无法表示为数字的内容。可以检查该参数中的原始值吗?顺便说一句,
$session->get()
也接受默认值作为第二个参数,因此您可以去掉该三元值。在分页器中设置为0的是
页面
而不是
plimit
,因此看起来像是强制错误,您得到的是无法用数字表示的内容。可以检查该参数中的原始值吗?顺便说一句,
$session->get()
还接受一个默认值作为第二个参数,因此您可以去掉该参数。