• Resolved wordpressdennis

    (@wordpressdennis)


    Hi, your restore_boot() function is called on just every load action in frontend, backend, ajax-calls. the simple session_start() line throws thousands of “session_start() will be ignored …” error log entries, if i try to start a session too in my coding.

    Could you please wrap your session_start just in an if-condition?

    if(session_status() === PHP_SESSION_NONE) {
    session_start(); // phpcs:ignore
    }

    I do so on my session_start, but somehow your session_start is not recognized as an active session, when i do my call. so my own if condition does not work.

    And by the way. Why is the function executed all the time. Isn’t it just necessary, if i want to do a backwpup restore?

    (Without checking by myself, if correct) ChatGPT suggests something like this for your session_start:

    if (is_admin() || (defined(‘DOING_AJAX’) && isset($_REQUEST[‘action’]) && $_REQUEST[‘action’] === ‘restore’)) {
    if (session_status() !== PHP_SESSION_ACTIVE) {
    session_start(); // phpcs:ignore
    }
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter wordpressdennis

    (@wordpressdennis)

    forgot the info about the related file:
    /backwpup/src/Infrastructure/Restore/commons.php

    at the end is your function with simple session_start() line.

    Plugin Support BWU Support

    (@saranshwpm)

    Hello,

    Thank you for bringing this to our attention. You are absolutely correct that session_start() should ideally only be used in the standalone app and not within WordPress. For WordPress, it’s recommended to store session-related data using options or usermeta, following WordPress best practices.

    We’ve noted your feedback, and I’ve shared it with our development team. We’ve taken this as a feature request, and hopefully, it will be considered for future updates to improve the way sessions are handled.

    As of now, there is no workaround or ETA for this change, but we appreciate your patience and understanding in the meantime.

    If you encounter any further issues or need help, feel free to reach out.

    Best Regards,

    Thread Starter wordpressdennis

    (@wordpressdennis)

    hi, thanks for your feedback. As of PHP 8.x – don’t know the exact minor version – this throws a lot of error log entries, if error logging is active:
    [25-Oct-2024 12:12:10 Europe/Berlin] PHP Notice: session_start(): Ignoring session_start() because a session is already active in /www/htdocs/…/wp-content/plugins/backwpup/src/Infrastructure/Restore/commons.php on line 358

    Imho to wrap your session_start() in a check of a session already existing should be no big deal, that does not need to be discussed, isn’t it? Additionally this session_start() is part of the – really cool!!! – new restore function of the free plugin. I am sure, it is not necessary, to execuute/initialize this functionality in the frontend of the website …. ??

    For now my workaround is just disabling error logging for this special error:
    set_error_handler(array($this, “customErrorHandler”));
    function customErrorHandler($errno, $errstr, $errfile, $errline) {
    if (strpos($errstr, ‘session_start(): Ignoring session_start()’) !== false) {
    return true;
    }
    return false;
    }

    Not ideal, but it allows me to keep my error logging active with being punished by BackWPUp.

    Plugin Support BWU Support

    (@saranshwpm)

    Hi,

    I have taken the note and added it to the escalated report for our developers.

    Thanks and regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.