Skip to content

Conversation

@natanael-aguiar
Copy link
Contributor

It's a little help, lately I needed to add the WordPress cron to DDEV-CRON and I had a lot of difficulty, here is a simple example. Added the cron example for WordPress in the readme.

Basically it will run the WordPress scheduler every 15 minutes and will also create a log file in the root of the project. If you didn't want the log file to be created, just remove this part of the code 2>&1 | tee -a /var/www/html/cron.log

Print(01) Change
image

Print(02, 03) Test
image

image

@tyler36 tyler36 mentioned this pull request Oct 4, 2023
@tyler36
Copy link
Collaborator

tyler36 commented Oct 4, 2023

Fixes #34

@rfay rfay changed the title Added cron example for WordPress in readme Added cron example for WordPress in readme, fixes #34 Oct 4, 2023
@natanael-aguiar
Copy link
Contributor Author

How wonderful, what is the next step now, do I need to do something on my side?

@tyler36
Copy link
Collaborator

tyler36 commented Oct 5, 2023

Thank you for the PR @natanael-oliveira .

I've never used WP so it was a good oppurtinuty to test the guides.

After following your PR, it does create cron.log, as expected, so ddev-cron is working with your guide.
However, cron.log contains the following line:

PHP Warning:  Undefined variable $table_prefix in /var/www/html/wp-settings.php on line 127
Warning: Undefined variable $table_prefix in /var/www/html/wp-settings.php on line 127
Error: Error establishing a database connection.

Is this something I should be worried about?

@natanael-aguiar
Copy link
Contributor Author

@tyler36 Can you send me a complete screenshot of your wp-config.php file? From my experience it seems that there is a configuration missing from this file, but nothing related to the change I made.

@tyler36
Copy link
Collaborator

tyler36 commented Oct 5, 2023

I uploaded the file as a gist: https://gist.github.com/tyler36/d0cccbaf3ddd4f5c420aeb3f19ca40c0

@natanael-aguiar
Copy link
Contributor Author

So @tyler36 from what I saw your wp-config file is missing the database connection entries, but as you can you are using ddev it usually also creates another connection file called wp-config-ddev.php, but basically you need have these definitions for connecting to the bank, I will leave an example code:

`<?php
/**

  • The base configuration for WordPress
  • The wp-config.php creation script uses this file during the installation.
  • You don't have to use the web site, you can copy this file to "wp-config.php"
  • and fill in the values.
  • This file contains the following configurations:
    • Database settings
    • Secret keys
    • Database table prefix
    • ABSPATH
  • @link https://wordpress.org/documentation/article/editing-wp-config-php/
  • @Package WordPress
    */

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** Database username */
define( 'DB_USER', 'username_here' );

/** Database password */
define( 'DB_PASSWORD', 'password_here' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+

  • Authentication unique keys and salts.
  • Change these to different unique phrases! You can generate these using
  • the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
  • You can change these at any point in time to invalidate all existing cookies.
  • This will force all users to have to log in again.
  • @SInCE 2.6.0
    */
    define( 'AUTH_KEY', 'put your unique phrase here' );
    define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
    define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
    define( 'NONCE_KEY', 'put your unique phrase here' );
    define( 'AUTH_SALT', 'put your unique phrase here' );
    define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
    define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
    define( 'NONCE_SALT', 'put your unique phrase here' );

/**#@-*/

/**

  • WordPress database table prefix.
  • You can have multiple installations in one database if you give each
  • a unique prefix. Only numbers, letters, and underscores please!
    */
    $table_prefix = 'wp_';

/**

  • For developers: WordPress debugging mode.
  • Change this to true to enable the display of notices during development.
  • It is strongly recommended that plugin and theme developers use WP_DEBUG
  • in their development environments.
  • For information on other constants that can be used for debugging,
  • visit the documentation.
  • @link https://wordpress.org/documentation/article/debugging-in-wordpress/
    */
    define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', DIR . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';`

@tyler36 tyler36 merged commit ae9adb3 into ddev:main Oct 6, 2023
@tyler36
Copy link
Collaborator

tyler36 commented Oct 6, 2023

@natanael-oliveira thanks for the update.

And thanks for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants