Hi, i been research 3days 3night without non stop to find the solution and i think its best solution for those who had this problem.

to

so the solution just that you needed only to replace or comment this code

to

i know there another alternative which is hide this coding

but it might had issue like temp wouldnt delete it and required to delete manually.
so best change the whole coding to fix export blank page issue include keep delete function.

  • myz likes this.
  • work well on osTicket version 1.18.xx

work well on osTicket version 1.18.xx

10 days later

Could you put the code here instead a picture?
Thanks in advance.
M.

5 months later

I had the same problem in my version 1.18.1:

  • I saw a white popup, without text and I didn't notice that the file was correctly sent to me via email.
  • also on line 2068 I had: "@$exporter->delete();" instead of "$exporter->delete();".

I made the suggested changes and now:

  • the file is correctly exported to the browser.
  • the popup is no longer white and without text but shows the courtesy text.

File edited on the image: \include\ajax.tickets.php

Code from image 1:

try {
    $interval = 5;
    $options = ['filename' => $filename,
                'interval' => $interval, 'delimiter' => $_POST['csv-delimiter']];
    // Create desired exporter
    $exporter = new CsvExporter($options);
    // Acknowledge the export
    $exporter->ack();
    // Phew... now we're free to do the export
    // Ask the queue to export to the exporter
    $queue->export($exporter);
    $exporter->finalize();
    // Email the export if it exists
    $exporter->email($thisstaff);
    // Delete the file.
    $exporter->delete();
    exit;
} catch (Exception $ex) {
    $errors['err'] = __('Unable to prepare the export');
}

Code from image 2:

try {
    $interval = 5;
    $options = ['filename' => $filename, 'interval' => $interval, 'delimiter' => $_POST['csv-delimiter']];
    // Create desired exporter
    $exporter = new CsvExporter($options);

    // Acknowledge the export
    $exporter->ack();

    // Phew... now we're free to do the export
    // Ask the queue to export to the exporter
    $queue->export($exporter);

    // Finalize the export process
    $exporter->finalize();

    // Email the export if it exists
    if ($exporter->exportExists()) {
        $exporter->email($thisstaff);
    } else {
        // Handle the case where the export file doesn't exist
        // This could be due to an error during the export process
        throw new Exception("Export file doesn't exist.");
    }

    // Delete the file after emailing
    $exporter->delete();

    exit;
} catch (Exception $e) {
    // Handle any exceptions that occur during the export process
    // Log the error or display an error message to the user
    echo "An error occurred: " . $e->getMessage();
}
    9 days later

    Cm-8

    I'm curious as to how you got this to work when exportExists() does not exist in core osTicket. Do you mean isAvailable() instead or did you add your own custom function?

    Cheers.

    I'm delving deeper into this and I simply cannot replicate it no matter what I try. However, through research and testing (and general knowledge of the codebase) I can indeed confirm exportExists() is not a real function. So how the above patch works when using exportExists() (a non-existing function) is it simply causes an uncaught error within the top-level of the try{} statement which causes it to immediately exit the queueExport() function and continue on. So without being able to replicate this, my best guess would be that within that email portion is causing some sort of fatal error that's not catchable by Exception or some sort of exit.

    It would be nice if someone that can replicate this can get back to me so we can further debug this and make a real fix. If someone can replicate this don't try the above patch as it's bogus; try simply changing the original } catch (Exception $ex) { to } catch (Throwable $ex) { and see if that helps any as that should catch whatever is thrown deeper down.

    2 months later

    miguelss Cm-8 Are either of you able to test my above suggestions? I am unable to replicate this issue.

      Hi KevinTheJedi you are awsom! Your professionalims is amaizing due to follow all the open issues :-)
      I can confirm that in may case, the problem was solved with the help of PHP Composer, that updated some packages:

      So, now is working fine, and I supposse you can't replicate the problem because you have already updated this packages.

      Thanks a lot for your help and your professionalism.
      Take care!

        5 days later
        • Edited

        KevinTheJedi

        Hello everyone,
        Sorry, I didn't see this before.
        I can test them if you want.

        I've change the code:

            } catch (Exception $ex) {
                // $errors['err'] = __('Unable to prepare the export');
        		// Handle any exceptions that occur during the export process
        		// Log the error or display an error message to the user
        		echo "An error occurred: " . $e->getMessage();
            }

        Into:

            } catch (Throwable $ex) {
                // $errors['err'] = __('Unable to prepare the export');
        		// Handle any exceptions that occur during the export process
        		// Log the error or display an error message to the user
        		echo "An error occurred: " . $e->getMessage();
            }

        And get the errors on console:

        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: PHP Fatal error: Uncaught Error: Call to a member function getMessage() on null in /var/www/vhosts/mysite.xx/support.mysite.xx/include/ajax.tickets.php:2068, referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: Stack trace:, referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: #0 /var/www/vhosts/mysite.xx/support.mysite.xx/include/ajax.tickets.php(2007): TicketsAjaxAPI->queueExport(), referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: #1 /var/www/vhosts/mysite.xx/support.mysite.xx/include/class.dispatcher.php(153): TicketsAjaxAPI->export(), referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: #2 /var/www/vhosts/mysite.xx/support.mysite.xx/include/class.dispatcher.php(40): UrlMatcher->dispatch(), referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: #3 /var/www/vhosts/mysite.xx/support.mysite.xx/include/class.dispatcher.php(119): Dispatcher->resolve(), referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: #4 /var/www/vhosts/mysite.xx/support.mysite.xx/include/class.dispatcher.php(40): UrlMatcher->dispatch(), referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: #5 /var/www/vhosts/mysite.xx/support.mysite.xx/scp/ajax.php(327): Dispatcher->resolve(), referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: #6 {main}, referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        2025-01-22 11:24:35	Warning	xx.xx.xx.xx		mod_fcgid: stderr: thrown in /var/www/vhosts/mysite.xx/support.mysite.xx/include/ajax.tickets.php on line 2068, referer: https://support.mysite.xx/scp/tickets.php?queue=6				Errore di Apache
        • Edited

        Since @KevinTheJedi was right, exportExists() does not exist, I reverted to the original function but caught more errors catch (Throwable $ex):

                    try {
                        $interval = 5;
                        $options = ['filename' => $filename,
                            'interval' => $interval, 'delimiter' => $_POST['csv-delimiter']];
                        // Create desired exporter
                        $exporter = new CsvExporter($options);
                        // Acknowledge the export
                        $exporter->ack();
                        // Phew... now we're free to do the export
                        // Ask the queue to export to the exporter
                        $queue->export($exporter);
                        $exporter->finalize();
                        // Email the export if it exists
                        $exporter->email($thisstaff);
                        // Delete the file.
                        @$exporter->delete();
                        exit;
                    } catch (Throwable $ex) {
                        $errors['err'] = __('Unable to prepare the export');
                    }

        In the console I only see:

        2025-01-22 11:36:21 Error xx.xx.xx.xx 404 GET /scp/ajax.php/export/fxuT5_/check HTTP/1.0 https://support.mysite.xx/scp/tickets.php?queue=6 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 495 Accesso SSL/TLS Apache

        2025-01-22 11:47:06 Error xx.xx.xx.xx 404 GET /scp/ajax.php/export/dUlZE0/check HTTP/1.0 https://support.mysite.xx/scp/tickets.php?queue=6 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 495 Accesso SSL/TLS Apache

          Cm-8

          And that's the same result from before? Getting a 404 error? Or is that new?

          Cheers.

          With the original code, but with catch (Throwable $ex) the result does not change:

          • The file is not exported and the popup in osticket remains white.

            Cm-8

            I get that, but I'm wondering if the error code is the same and everything so I can narrow this down.

            So what this likely means is something within the $exporter->email($thisstaff); part is crapping out causing the issue or it gets skipped too fast and goes on to delete() which would make the /check call fail (although we should be returning an error in a way the popup wouldn't crap out). Also, idk why throwable can't catch whatever is happening there unless it's simply not throwing an error but skipping past it real fast. 🤔

            Cheers.

            • Cm-8 replied to this.
              • Edited

              With:

                          } catch (Exception $ex) {
                              $errors['err'] = __('Unable to prepare the export');
              		echo "An error occurred: " . $e->getMessage();
                          }

              or:

                          } catch (Throwable $ex) {
                              $errors['err'] = __('Unable to prepare the export');
              		echo "An error occurred: " . $e->getMessage();
                          }

              The error on Plesk log console is the same:

              • 404 GET /scp/ajax.php/export/pE1drK/check HTTP/1.0
              • 404 GET /scp/ajax.php/export/bmS1el/check HTTP/1.0

              KevinTheJedi
              Based on your suggestion, I commented the line:

              // Delete the file.
              // @$exporter->delete();

              And everything worked fine.

              So yes, I confirm your hypothesis: $exporter->email($thisstaff); for some reason is executed too slowly and the subsequent @$exporter->delete(); deletes the file too early.

              Unfortunately the error is not intercepted by the two methods you indicated.

              With PHP X-RAY i see that there is a sleep function on /include/class.export.php:516 that take 15 sec.
              I try to add a sleep(20); before @$exporter->delete(); but nothing changed.
              No different errors on apache log.

              Write a Reply...