wp-cli / i18n-command

Provides internationalization tools for WordPress projects.
MIT License
96 stars 52 forks source link

i18n make-pot database required? #345

Closed Reaper88 closed 1 year ago

Reaper88 commented 1 year ago

Bug Report

Describe the current, buggy behavior

When I try to make a pot from just plugins files I get this error:

Error: Error establishing a database connection.
Script wp i18n make-pot . languages/<filename>.pot handling the make-pot event returned with error code 1

I am running a minimal setup working with wordpress in a docker image using volumes to link to the image for developement but doesn't work. I'm wondering why does it need to connect to database just for making a pot file

Describe how other contributors can replicate this bug

Make a pot file without the need for the databse.

Let us know what environment you are running this on

OS:     Linux 4.18.0-372.26.1.el8_6.x86_64 #1 SMP Tue Sep 13 18:09:48 UTC 2022 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php
PHP version:    7.4.32
php.ini used:   /etc/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.5.16-MariaDB, for Linux (x86_64) using  EditLine wrapper
SQL modes:
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /home/kevin/web/Geca/wp-content/themes/geca
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.6.0

Provide additional context/Screenshots

I am running these as a volume for a docker image and database as an image and it is running but since wp-config is within the files of the docker image it cannot reach it therefore blocking the process at database level.

swissspidy commented 1 year ago

None of the i18n commands require a database connection or a WordPress installation.

Reaper88 commented 1 year ago

Then why am I receiving this error of database connection and no files?

danielbachhuber commented 1 year ago

@Reaper88 wp i18n make-pot seems to work fine for me without a database connection:

$ wp core download
Downloading WordPress 6.1.1 (en_US)...
md5 hash verified: 38a0a4f7b7ec8429b2fe96de6b5d6572
Success: WordPress downloaded.
$ mkdir languages
$ wp i18n make-pot . languages/filename.pot
Success: POT file successfully generated!

Can you reproduce the issue in another environment? If not, it might be a problem specific to your environment. Feel free to stop by the #cli channel on WordPress.org Slack if you'd like help debugging further.

Reaper88 commented 1 year ago

I'm not sure why exactly, or if it was my code or my environment, but I was running the command first in composer which never gave me issues before, and I decided to try running the command directly, that worked, tried composer again, and then it worked too all of a sudden. Sorry for the trouble at least it works, it could be due to using composer first I'll have to try that again later down the road.

danielbachhuber commented 1 year ago

Sounds good, thanks @Reaper88