Skip to content

How to use retryHandler #19429

Closed Answered by ghost
EtienneBruines asked this question in Q&A
Jun 9, 2022 · 2 comments · 7 replies
Discussion options

You must be logged in to vote

This is almost right but doesn't quite work because the prepared query already has the database connection inside of it (so it will fail forever because the old connection is gone), so after the DB reconnects, we actually have to re-create the query using the new database connection.

Here's a working version I used to stop our scripts from crashing when the VPN disconnects:

/* hack str_contains into the current environment if it doesn't exist */
if (!function_exists('str_contains')) {
    function str_contains (string $haystack, string $needle)
    {
        return empty($needle) || strpos($haystack, $needle) !== false;
    }
}

assert(function_exists('str_contains'));

/* Adapted from: h…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
4 replies
@EtienneBruines
Comment options

@WinterSilence
Comment options

@EtienneBruines
Comment options

@WinterSilence
Comment options

Comment options

You must be logged in to vote
3 replies
@ghost
Comment options

Answer selected by terabytesoftw
@WinterSilence
Comment options

@ghost
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants