• Andis

    (@andydegroo)


    I was trying to extract strings for Jetpack by running

    > wp loco extract plugins:jetpack/jetpack.php

    I see a bunch of PHP warnings about preg_match() regex being too long in the output:

    Warning: preg_match(): Compilation failed: regular expression is too large at offset 57961 in ../wp-content/plugins/loco-translate/lib/compiled/gettext.php:269
    Stack trace:
    #1 ../wp-content/plugins/loco-translate/lib/compiled/gettext.php(269): preg_match
    #2 ../wp-content/plugins/loco-translate/lib/compiled/gettext.php(267): LocoExtracted->mergeField
    #3 ../wp-content/plugins/loco-translate/lib/compiled/gettext.php(284): LocoExtracted->pushEntry
    #4 ../wp-content/plugins/loco-translate/lib/compiled/gettext.php(324): LocoExtractor->push
    #5 ../wp-content/plugins/loco-translate/lib/compiled/gettext.php(259): LocoPHPExtractor->extract
    #6 ../wp-content/plugins/loco-translate/src/gettext/Extraction.php(122): LocoExtracted->extractSource
    #7 ../wp-content/plugins/loco-translate/src/cli/ExtractCommand.php(39): Loco_gettext_Extraction->addProject
    #8 ../wp-content/plugins/loco-translate/src/cli/Commands.php(83): Loco_cli_ExtractCommand::run
    #9 php_native(0): Loco_cli_Commands->extract
    #10 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func
    #11 php_native(0): WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}
    #12 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(497): call_user_func
    #13 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(470): WP_CLI\Dispatcher\Subcommand->invoke
    #14 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(493): WP_CLI\Runner->run_command
    #15 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1295): WP_CLI\Runner->run_command_and_exit
    #16 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(28): WP_CLI\Runner->start
    #17 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(84): WP_CLI\Bootstrap\LaunchRunner->process
    #18 phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(35): WP_CLI\bootstrap
    #19 phar:/usr/local/bin/wp/php/boot-phar.php(20): include('phar:/usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php')
    #20 /usr/local/bin/wp(4): include('phar:/usr/local/bin/wp/php/boot-phar.php')

    After about twelve minutes I hit Ctrl+C to cancel the process. Something doesn’t seem right here.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tim W

    (@timwhitlock)

    It looks like it’s trying to merge comments from multiple instances of the same string and those comments have become very long. Possibly the comment is not intended to annotate to the string, but the code assumes it is.

    The regex is built from the comment string itself, and it seems I’d not anticipated that to be a problem. Evidently I need to rewrite that code to handle very long comments. I don’t have time to fix this right now, but I’ll take a look as soon as I can.

    I’d recommend for now that you use WordPress’s own make-pot command. See i18n-command.

    Thread Starter Andis

    (@andydegroo)

    Thanks for recommending the i18n-command. I wasn’t aware it existed. It worked like a charm.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.