title: Using Facebook API (via Symfony) leads to multiple post on my Page wall
body: <p>I've got a problem while auto-posting my blog articles on Facebook. I've been looking everywhere on the web to find a solution but it seems I'm the only one to face this problem.</p>
  
  <p>Here are all the informations:</p>
  
  <ul>
  <li>I am using Symfony 3 for my blog</li>
  <li>I save a "publicationDate" ($article->getPublicationDate()) to postpone article publication and a "hasBeenSentOnSocialNetworks" (($article->getIsOnline()) boolean to know if it has been sent on Twitter and Facebook wall</li>
  <li>I've set a controller action to check if there is any article to set online.</li>
  <li>When the controller is called, I get a list of offline articles (publicationDate &lt; now AND getIsOnline == false)</li>
  <li>Each of them is then pushed on social networks, thanks to the great bundle of Martin Georgiev (<a href="https://github.com/martin-georgiev/social-post-bundle" rel="nofollow noreferrer">https://github.com/martin-georgiev/social-post-bundle</a>)</li>
  <li>Finally, I flush $article->setIsOnline(true) to avoid posting every time, once it's done.</li>
  </ul>
  
  <p>Everything works just fine as Twitter publish my articles and Facebook too. My database saved isOnline = true.</p>
  
  <p>With OVH I can only run CRON task every hour. The CRON task does the job perfectly with only 1 post published on social networks for every article. My CRON is calling a file that use curl to open the page of the controller that handles the publication.</p>
  
  <p>But to have better reaction time, I've tried adding an event in Symfony so that every time a page is loaded, it checks if there are articles to publish on social networks. This worked fine, excepted I had 2 articles posted on Twitter and about 20-30 on Facebook... I've tried everyting : kernel.response, kernel.controller, kernel.request and I've made a "return;" if the event is not MASTER_REQUEST. No success.</p>
  
  <p>Then I've decided to use twig to call the controller opened by my CRON task. I have added at the bottom of my base.html.twig a "{{ render(controller(....)) }}". It works fine for Twitter with only one post. But on Facebook it sends dozen of time the same publication.</p>
  
  <p>I'm kinda lost. It's been days now that I am trying to fix that. Any help or advice would be appreciated! Thanks :)</p>
  
  <p>My controller action:
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$repository = $this-&gt;getDoctrine()-&gt;getRepository(Article::class);
  $articles = $repository-&gt;findAllOfflineArticles();
  
    foreach ($articles as $article) {
      $content = $article-&gt;getSocialContent();
  
      if($content == null){
        $content = $article-&gt;getTitle();
      }
  
      $link = $this-&gt;get('router')-&gt;generate('article_show', array('slug' =&gt;       $article-&gt;getSlug()), UrlGeneratorInterface::ABSOLUTE_URL);
      // Post on social networks
      $message = new \MartinGeorgiev\SocialPost\Provider\Message($content, $link);
      $this-&gt;get('social_post')-&gt;publish($message);
      //
  
      $article-&gt;setIsOnline(true);
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $em-&gt;persist($article);
      $em-&gt;flush();
    }</code></pre>
  </div>
  </div>
  </p>
  
  <p>---------------- <strong>EDIT 1</strong> ----------------</p>
  
  <p>Thanks to @AhmetGunes for opening my eyes. I've been looking for the error everywhere in my code and I have tried so many different things that my understanding of the situation was blurred. It seems the problem was just as the following:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public function findAllOfflineArticles(){
    return $this
     -&gt;createQueryBuilder('a')
     -&gt;where('a.isPublished = :is_published')
     -&gt;andWhere('a.isValidated = :is_validated')
     -&gt;andWhere('a.isOnline &lt;= :is_online')
     -&gt;andWhere('a.publicationDate &lt;= :now')
     -&gt;setParameter('now', new \Datetime())
     -&gt;setParameter('is_published', true)
     -&gt;setParameter('is_validated', true)
     -&gt;setParameter('is_online', false)
     -&gt;orderBy('a.publicationDate', 'ASC')
     -&gt;getQuery()
     -&gt;getResult()
    ;
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The problem was obvious, despite I don't really understand how it was working this way.
  The query was fetching <pre>->andWhere('a.isOnline &lt;= :is_online')</pre>
  I corrected this big mistake :<pre>->andWhere('a.isOnline = :is_online')</pre> and got only one post on facebook!</p>
  
  <p>However, why didn't Doctrine told me there was a problem with my request? How come the script wasn't launching again once isOnline was set to true ?</p>
  
  <p>---------------- <strong>EDIT 2</strong> ----------------</p>
  
  <p>The correction worked properly two times. But now it's back as before. Exactly 28-29 publications on Facebook. I'm definitively exhausted of this. This is driving me crazy.</p>