Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
Zend Framework's JsPush adapter only refreshing progress once the PHP script is finished

Since we switched a project from PHP 5 to 7.4, something odd is happening, although I doubt it's a PHP thing, but please hear me out first.

The HTML/PHP project uses the Zend_ProgressBar_Adapter_JsPush class of the Zend Framework.

There's an HTML button on screen. Once it's clicked, a PHP script is running in the background and calling the update method of the Zend_ProgressBar class. After each step the PHP script does/finishes, the value goes up by +20, until 100 is reached.

There is also an HTML table. 2nd column showing a load-icon before the results of each step coming in. There are 5 rows in that table, so one row for each step.

Now here's the situation: During the times of PHP5 when the PHP script was running, the user could see which step the PHP script has reached/finished so far, but now with PHP7.4 in use, ALL fields are getting updated once the PHP script is finished. They are shown correctly, but the problem is that it doesn't refresh step by step anymore.

It's like everything is getting queued in the background or something, and JavaScript doesn't get the chance to update any fields "live", so it does it at the end of the PHP script.

I got no clue what the reason is. I even tried to add sleep(5) between these steps, and I saw it was working. But why letting the user wait 5 times 5 seconds if there could be a better solution?

Here's the (light version) of the PHP code:

$adapter = new Zend_ProgressBar_Adapter_JsPush();
$adapter->setUpdateMethodName('Zend_ProgressBar_Update');
$adapter->setFinishMethodName('Zend_ProgressBar_Finish');

$progress = new Zend_ProgressBar($adapter, 0, 100);
$result = "";
$progress->update(0, $result);
// Do something...
$progress->update(20, $result);
// [...]
$progress->update(100, $result);

JavaScript methods:

function Zend_ProgressBar_Update(data)
{
    switch (data.current) {
        case 0:
        /* Reset progress table */
        /* [...] */
        break;
    case 20:
        /* Fill first row column of table with data.text */
        /* [...] */
        break;
    /* [...] */
    case 100:
        /* Fill final row column of table with data.text */
        /* [...] */
        break;
    default:
        //alert('default');
        break;
}

function Zend_ProgressBar_Finish()
{
    alert('Finished');
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda