Mpdf \ MpdfException (E_ERROR)
The HTML code size is larger than pcre.backtrack_limit 5000000. You should use WriteHTML() with smaller string lengths. Pass your HTML in smaller chunks. Mpdf\MpdfException thrown with message "The HTML code size is larger than pcre.backtrack_limit 5000000. You should use WriteHTML() with smaller string lengths. Pass your HTML in smaller chunks." Stacktrace: #10 Mpdf\MpdfException in /home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/vendor/mpdf/mpdf/src/Mpdf.php:27072 #9 Mpdf\Mpdf:AdjustHTML in /home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/vendor/mpdf/mpdf/src/Mpdf.php:13437 #8 Mpdf\Mpdf:WriteHTML in /home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/app/Modules/PdfGenerator/PdfGenerator.php:226 #7 App\Modules\PdfGenerator\PdfGenerator:generate in /home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/app/Modules/PdfGenerator/PdfGenerator.php:103 #6 App\Modules\PdfGenerator\PdfGenerator:getFile in /home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/app/Modules/PdfGenerator/PdfGeneratorServiceProvider.php:56 #5 App\Modules\PdfGenerator\PdfGeneratorServiceProvider:App\Modules\PdfGenerator\{closure} in /home/juwent/domains/juwent.com.pl/public_html/wp-includes/class-wp-hook.php:324 #4 WP_Hook:apply_filters in /home/juwent/domains/juwent.com.pl/public_html/wp-includes/class-wp-hook.php:348 #3 WP_Hook:do_action in /home/juwent/domains/juwent.com.pl/public_html/wp-includes/plugin.php:517 #2 do_action in /home/juwent/domains/juwent.com.pl/public_html/wp-includes/template-loader.php:13 #1 require_once in /home/juwent/domains/juwent.com.pl/public_html/wp-blog-header.php:19 #0 require in /home/juwent/domains/juwent.com.pl/public_html/index.php:17
Stack frames (11)
10
Mpdf\MpdfException
/vendor/mpdf/mpdf/src/Mpdf.php27072
9
Mpdf\Mpdf AdjustHTML
/vendor/mpdf/mpdf/src/Mpdf.php13437
8
Mpdf\Mpdf WriteHTML
/app/Modules/PdfGenerator/PdfGenerator.php226
7
App\Modules\PdfGenerator\PdfGenerator generate
/app/Modules/PdfGenerator/PdfGenerator.php103
6
App\Modules\PdfGenerator\PdfGenerator getFile
/app/Modules/PdfGenerator/PdfGeneratorServiceProvider.php56
5
App\Modules\PdfGenerator\PdfGeneratorServiceProvider App\Modules\PdfGenerator\{closure}
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/class-wp-hook.php324
4
WP_Hook apply_filters
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/class-wp-hook.php348
3
WP_Hook do_action
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/plugin.php517
2
do_action
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/template-loader.php13
1
require_once
/home/juwent/domains/juwent.com.pl/public_html/wp-blog-header.php19
0
require
/home/juwent/domains/juwent.com.pl/public_html/index.php17
/home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/vendor/mpdf/mpdf/src/Mpdf.php
        $html = str_replace("'", "'", $html);
        $html = str_replace(""", '"', $html);
        $html = str_replace("&", "&", $html);
 
        return $html;
    }
 
    function AdjustHTML($html, $tabSpaces = 8)
    {
        $limit = ini_get('pcre.backtrack_limit');
 
        if (0 >= (int) $limit) {
            throw new \Mpdf\MpdfException(sprintf(
                'mPDF will not process HTML with disabled pcre.backtrack_limit to prevent unexpected behaviours, please set a positive backtrack limit.',
                $limit
            ));
        }
 
        if (strlen($html) > (int) $limit) {
            throw new \Mpdf\MpdfException(sprintf(
                'The HTML code size is larger than pcre.backtrack_limit %d. You should use WriteHTML() with smaller string lengths. Pass your HTML in smaller chunks.',
                $limit
            ));
        }
 
        preg_match_all("/(<annotation.*?>)/si", $html, $m);
        if (count($m[1])) {
            for ($i = 0; $i < count($m[1]); $i++) {
                $sub = preg_replace("/\n/si", Mpdf::OBJECT_IDENTIFIER, $m[1][$i]);
                $html = preg_replace('/' . preg_quote($m[1][$i], '/') . '/si', $sub, $html);
            }
        }
 
        preg_match_all("/(<svg.*?<\/svg>)/si", $html, $svgi);
        if (count($svgi[0])) {
            for ($i = 0; $i < count($svgi[0]); $i++) {
                $file = $this->cache->write('/_tempSVG' . uniqid(random_int(1, 100000), true) . '_' . $i . '.svg', $svgi[0][$i]);
                $html = str_replace($svgi[0][$i], '<img src="' . $file . '" />', $html);
            }
        }
Arguments
  1. "The HTML code size is larger than pcre.backtrack_limit 5000000. You should use WriteHTML() with smaller string lengths. Pass your HTML in smaller chunks."
    
/home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/vendor/mpdf/mpdf/src/Mpdf.php
            // Close any open block tags
            $arr = [];
            $ai = 0;
            for ($b = $this->blklvl; $b > 0; $b--) {
                $this->tag->CloseTag($this->blk[$b]['tag'], $arr, $ai);
            }
            // Output any text left in buffer
            if (count($this->textbuffer)) {
                $this->printbuffer($this->textbuffer);
            }
            $this->bufferoutput = true;
            $this->textbuffer = [];
            $this->headerbuffer = '';
            $properties = $this->cssManager->MergeCSS('BLOCK', 'BODY', '');
            $this->setCSS($properties, '', 'BODY');
        }
 
        mb_internal_encoding('UTF-8');
 
        $html = $this->AdjustHTML($html, $this->tabSpaces); // Try to make HTML look more like XHTML
 
        if ($this->autoScriptToLang) {
            $html = $this->markScriptToLang($html);
        }
 
        preg_match_all('/<htmlpageheader([^>]*)>(.*?)<\/htmlpageheader>/si', $html, $h);
        for ($i = 0; $i < count($h[1]); $i++) {
            if (preg_match('/name=[\'|\"](.*?)[\'|\"]/', $h[1][$i], $n)) {
                $this->pageHTMLheaders[$n[1]]['html'] = $h[2][$i];
                $this->pageHTMLheaders[$n[1]]['h'] = $this->_getHtmlHeight($h[2][$i]);
            }
        }
        preg_match_all('/<htmlpagefooter([^>]*)>(.*?)<\/htmlpagefooter>/si', $html, $f);
        for ($i = 0; $i < count($f[1]); $i++) {
            if (preg_match('/name=[\'|\"](.*?)[\'|\"]/', $f[1][$i], $n)) {
                $this->pageHTMLfooters[$n[1]]['html'] = $f[2][$i];
                $this->pageHTMLfooters[$n[1]]['h'] = $this->_getHtmlHeight($f[2][$i]);
            }
        }
 
/home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/app/Modules/PdfGenerator/PdfGenerator.php
 
        $mpdf->SetWatermarkImage(get_attached_file(55138), 0.05, [100, 70]);
 
        $mpdf->showWatermarkImage = true;
 
        ini_set("pcre.backtrack_limit", "5000000");
 
 
 
        $mpdf->WriteHTML(
            view('pdf.body', [
                'reference' => $this->data['reference'],
                'name' => $this->post->post_title,
                'short_description' => $this->data['short_description'],
                'description' => $this->data['description'],
                'thumbnail' => $this->data['thumbnail'],
                'variants' => $variants,
                'lang' => $this->lang->getLanguageCode(),
                'headers' => [
                    'description' => TranslationService::getTranslatedString('Opis', $this->lang->getLanguageCode()),
                ]
            ])
        );
 
        if (!file_exists($this->uploadPath)) {
            mkdir($this->uploadPath, 0755, true);
        }
 
        $mpdf->Output(self::filePath($pdfName, $this->lang->getLanguageCode()), \Mpdf\Output\Destination::FILE);
 
        if ($existingEntryId != null) {
 
            if ($this->variant != null) {
                $this->db->updateEntry($existingEntryId, $this->lang->getLanguageCode(), $pdfName, $this->data['modified'], $this->variant);
            } else {
                $this->db->updateEntry($existingEntryId, $this->lang->getLanguageCode(), $pdfName, $this->data['modified']);
            }
        } else {
            if ($this->variant != null) {
                $this->db->saveEntry($this->post->ID, $this->lang->getLanguageCode(), $pdfName, $this->data['modified'], $this->variant);
/home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/app/Modules/PdfGenerator/PdfGenerator.php
    }
 
    public static function needsUpdate(string $updated, string $modified): bool
    {
        $post_mod = strtotime($modified);
        $file_mod = strtotime($updated);
 
        return $post_mod != $file_mod ? true : false;
    }
 
    public function getFile(): void
    {
        if ($this->db->entryExists($this->post->ID, $this->lang->getLanguageCode(), $this->variant)) {
            $entry = $this->db->getEntry($this->post->ID, $this->lang->getLanguageCode(), $this->variant);
 
            // if ($this->needsUpdate($entry->updated_at, $this->data['modified'])) {
            $entry = $this->generate($entry->id);
            // }
        } else {
            $entry = $this->generate();
        }
 
        if (file_exists($entry->path)) {
            header('Content-Description: File Transfer');
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename=' . basename($entry->path));
            header('Content-Transfer-Encoding: binary');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Pragma: public');
            header('Content-Length: ' . filesize($entry->path));
            ob_clean();
            flush();
            readfile($entry->path);
            exit;
        }
    }
 
    public function normalizeString($str = ''): string
    {
/home/juwent/domains/juwent.com.pl/public_html/wp-content/themes/juwent/app/Modules/PdfGenerator/PdfGeneratorServiceProvider.php
    private function addQueryVars(): void
    {
        add_filter('query_vars', function (array $vars) {
            $vars[] = '_pdfId';
            $vars[] = 'variantSlug';
            return $vars;
        });
    }
 
    private function handleTemplateRedirect(): void
    {
        add_action('template_redirect', function () {
 
            if (get_query_var('_pdfId') && get_query_var('variantSlug')) {
 
                $postId = get_query_var('_pdfId');
                $variantSlug = get_query_var('variantSlug');
 
                $generator = app()->make(PdfGeneratorInterface::class, ['postId' => $postId, 'variantSlug' => $variantSlug]);
                $generator->getFile();
                die();
            } elseif ($postId = get_query_var('_pdfId')) {
 
                $pdf = app()->make(PdfGeneratorInterface::class, ['postId' => $postId]);
                $pdf->getFile();
                die();
            }
        });
    }
}
 
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/class-wp-hook.php
 
        $this->iterations[ $nesting_level ] = $this->priorities;
 
        $num_args = count( $args );
 
        do {
            $this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );
 
            $priority = $this->current_priority[ $nesting_level ];
 
            foreach ( $this->callbacks[ $priority ] as $the_ ) {
                if ( ! $this->doing_action ) {
                    $args[0] = $value;
                }
 
                // Avoid the array_slice() if possible.
                if ( 0 === $the_['accepted_args'] ) {
                    $value = call_user_func( $the_['function'] );
                } elseif ( $the_['accepted_args'] >= $num_args ) {
                    $value = call_user_func_array( $the_['function'], $args );
                } else {
                    $value = call_user_func_array( $the_['function'], array_slice( $args, 0, $the_['accepted_args'] ) );
                }
            }
        } while ( false !== next( $this->iterations[ $nesting_level ] ) );
 
        unset( $this->iterations[ $nesting_level ] );
        unset( $this->current_priority[ $nesting_level ] );
 
        --$this->nesting_level;
 
        return $value;
    }
 
    /**
     * Calls the callback functions that have been added to an action hook.
     *
     * @since 4.7.0
     *
     * @param array $args Parameters to pass to the callback functions.
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/class-wp-hook.php
        } while ( false !== next( $this->iterations[ $nesting_level ] ) );
 
        unset( $this->iterations[ $nesting_level ] );
        unset( $this->current_priority[ $nesting_level ] );
 
        --$this->nesting_level;
 
        return $value;
    }
 
    /**
     * Calls the callback functions that have been added to an action hook.
     *
     * @since 4.7.0
     *
     * @param array $args Parameters to pass to the callback functions.
     */
    public function do_action( $args ) {
        $this->doing_action = true;
        $this->apply_filters( '', $args );
 
        // If there are recursive calls to the current action, we haven't finished it until we get to the last one.
        if ( ! $this->nesting_level ) {
            $this->doing_action = false;
        }
    }
 
    /**
     * Processes the functions hooked into the 'all' hook.
     *
     * @since 4.7.0
     *
     * @param array $args Arguments to pass to the hook callbacks. Passed by reference.
     */
    public function do_all_hook( &$args ) {
        $nesting_level                      = $this->nesting_level++;
        $this->iterations[ $nesting_level ] = $this->priorities;
 
        do {
            $priority = current( $this->iterations[ $nesting_level ] );
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/plugin.php
    if ( ! isset( $wp_filter[ $hook_name ] ) ) {
        if ( isset( $wp_filter['all'] ) ) {
            array_pop( $wp_current_filter );
        }
 
        return;
    }
 
    if ( ! isset( $wp_filter['all'] ) ) {
        $wp_current_filter[] = $hook_name;
    }
 
    if ( empty( $arg ) ) {
        $arg[] = '';
    } elseif ( is_array( $arg[0] ) && 1 === count( $arg[0] ) && isset( $arg[0][0] ) && is_object( $arg[0][0] ) ) {
        // Backward compatibility for PHP4-style passing of `array( &$this )` as action `$arg`.
        $arg[0] = $arg[0][0];
    }
 
    $wp_filter[ $hook_name ]->do_action( $arg );
 
    array_pop( $wp_current_filter );
}
 
/**
 * Calls the callback functions that have been added to an action hook, specifying arguments in an array.
 *
 * @since 2.1.0
 *
 * @see do_action() This function is identical, but the arguments passed to the
 *                  functions hooked to `$hook_name` are supplied using an array.
 *
 * @global WP_Hook[] $wp_filter         Stores all of the filters and actions.
 * @global int[]     $wp_actions        Stores the number of times each action was triggered.
 * @global string[]  $wp_current_filter Stores the list of current filters with the current one last.
 *
 * @param string $hook_name The name of the action to be executed.
 * @param array  $args      The arguments supplied to the functions hooked to `$hook_name`.
 */
function do_action_ref_array( $hook_name, $args ) {
/home/juwent/domains/juwent.com.pl/public_html/wp-includes/template-loader.php
<?php
/**
 * Loads the correct template based on the visitor's url
 *
 * @package WordPress
 */
if ( wp_using_themes() ) {
    /**
     * Fires before determining which template to load.
     *
     * @since 1.5.0
     */
    do_action( 'template_redirect' );
}
 
/**
 * Filters whether to allow 'HEAD' requests to generate content.
 *
 * Provides a significant performance bump by exiting before the page
 * content loads for 'HEAD' requests. See #14348.
 *
 * @since 3.5.0
 *
 * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true.
 */
if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) {
    exit;
}
 
// Process feeds and trackbacks even if not using themes.
if ( is_robots() ) {
    /**
     * Fired when the template loader determines a robots.txt request.
     *
     * @since 2.1.0
     */
    do_action( 'do_robots' );
    return;
} elseif ( is_favicon() ) {
    /**
/home/juwent/domains/juwent.com.pl/public_html/wp-blog-header.php
<?php
/**
 * Loads the WordPress environment and template.
 *
 * @package WordPress
 */
 
if ( ! isset( $wp_did_header ) ) {
 
    $wp_did_header = true;
 
    // Load the WordPress library.
    require_once __DIR__ . '/wp-load.php';
 
    // Set up the WordPress query.
    wp();
 
    // Load the theme template.
    require_once ABSPATH . WPINC . '/template-loader.php';
 
}
 
Arguments
  1. "/home/juwent/domains/juwent.com.pl/public_html/wp-includes/template-loader.php"
    
/home/juwent/domains/juwent.com.pl/public_html/index.php
<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */
 
/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define( 'WP_USE_THEMES', true );
 
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';
 
Arguments
  1. "/home/juwent/domains/juwent.com.pl/public_html/wp-blog-header.php"
    

Environment & details:

Key Value
lang
"pl"
empty
empty
Key Value
wp-wpml_current_language
"pl"
empty
Key Value
SERVER_SOFTWARE
"Apache/2"
REQUEST_URI
"/pdf/1191/dsp-1/?lang=pl"
PATH
"/usr/local/bin:/usr/bin:/bin"
TEMP
"/tmp"
TMP
"/tmp"
TMPDIR
"/tmp"
PWD
"/"
HTTP_ACCEPT
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_ENCODING
"br,gzip"
HTTP_ACCEPT_LANGUAGE
"en-US,en;q=0.5"
HTTP_CONNECTION
"close"
CONTENT_LENGTH
"0"
HTTP_HOST
"juwent.com.pl"
HTTP_USER_AGENT
"CCBot/2.0 (https://commoncrawl.org/faq/)"
HTTP_X_FORWARDED_FOR
"34.239.158.223"
HTTP_X_ACCEL_INTERNAL
"/nginx_static_files"
REDIRECT_UNIQUE_ID
"ZlVkTqin5rop4TzYy1xaagAAACo"
REDIRECT_HTTP_AUTHORIZATION
""
REDIRECT_HTTPS
"on"
REDIRECT_STATUS
"200"
UNIQUE_ID
"ZlVkTqin5rop4TzYy1xaagAAACo"
HTTP_AUTHORIZATION
""
HTTPS
"on"
SERVER_SIGNATURE
""
SERVER_NAME
"juwent.com.pl"
SERVER_ADDR
"144.76.242.41"
SERVER_PORT
"443"
REMOTE_ADDR
"34.239.158.223"
DOCUMENT_ROOT
"/home/juwent/domains/juwent.com.pl/private_html"
REQUEST_SCHEME
"https"
CONTEXT_PREFIX
""
CONTEXT_DOCUMENT_ROOT
"/home/juwent/domains/juwent.com.pl/private_html"
SERVER_ADMIN
"webmaster@juwent.com.pl"
SCRIPT_FILENAME
"/home/juwent/domains/juwent.com.pl/private_html/index.php"
REMOTE_PORT
"47182"
REDIRECT_URL
"/pdf/1191/dsp-1/"
REDIRECT_QUERY_STRING
"lang=pl"
SERVER_PROTOCOL
"HTTP/1.0"
REQUEST_METHOD
"GET"
QUERY_STRING
"lang=pl"
SCRIPT_NAME
"/index.php"
PHP_SELF
"/index.php"
REQUEST_TIME_FLOAT
1716872270.5176
REQUEST_TIME
1716872270
APP_URL
"https://juwent.com.pl"
APP_ENV
"production"
APP_DEBUG
"false"
THEME_NAME
"juwent"
Key Value
APP_URL
"https://juwent.com.pl"
APP_ENV
"production"
APP_DEBUG
"false"
THEME_NAME
"juwent"
0. Whoops\Handler\PrettyPageHandler