0

LAMP CentOS (CPanel) PHP-FPM PHP 7.3 Wordpress 6.2.2 Civi version: civicrm-5.62.1-wordpress "the_website" = redaction from the actual user + website :)

I keep running into this problem ever since we upgraded the last two times. The last time I upgraded was because of this same error. It works for a while then breaks seemingly for no reason! Can I disable this api4 security check? It's crashing the site constantly! I had upgraded the site to PHP 8.1 but CIVI was using some kind of mail tracking header for "no_reply@the_website.net" to some kind of GUID_tracker@the_website.net", so I back rev'd to PHP 7.3 and that fixed the odd email problem. Then it started crashing the site for no reason.

Error:
thrown in /home/the_website/civi.the_website.net/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php on line 232 [23-Jun-2023 06:02:15 UTC] PHP Fatal error:  Uncaught CRM_Core_Exception: [unauthorized: Authorization failed

My cron is killed that does an api call to send mail and when I tried to run the flush cache command manually just to see what it does, it also fails.

[~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli]# /opt/cpanel/ea-php73/root/usr/bin/php ~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli/cv.phar flush --cwd=/home/the_website/civi.the_website.net/
In Kernel.php line 232:
Authorization failed
flush [-T|--triggers] [--level LEVEL] [--hostname HOSTNAME] [-t|--test] [-U|--user USER]

^ I also tried it with the "admin" user flag, same results

Again, this worked fine and dandy after yesterdays upgrade and the website became usable again. Then, after some time, perhaps with some other thing running on civi in the background, it breaks at like 6am every morning like it did on Wednesday. Can someone help me to turn off these security checks until these bugs get worked out?

Here is my cron which calls the admin user but still fails: */5 * * * * /opt/cpanel/ea-php73/root/usr/bin/php ~/civi.the_website.net/wp-content/plugins/civicrm/wp-cli/cv.phar api job.process_mailing --user=admin --cwd=/home/the_website/civi.the_website.net/ > ~/civi.the_website.net/cron.log

I'm hurt'n LOL, thanks!

1 Answer 1

1

The cron job needs to call wp not civicrm/wp-cli/cv.phar

I'd suggest */5 * * * * /opt/cpanel/ea-php73/root/usr/bin/php wp cv api job.process_mailing --user=admin --path=/home/the_website/civi.the_website.net/ auth=0

In place of wp you may need to full path to the wp-cli script on the server. I have to install this myself on most cpanel servers. Instructions are here: https://wp-cli.org/#installing

CiviCRM's documentation is at https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/#wp-cli

Added from Comments:

that's what it was! I restored the /home/user_dir/subdomain.domain.net/wp-content/uploads/civicrm > edited the civicrm.settings.php to reflect a new password without special characters > changed the db user password to that and it came right up. Warning to any and all, no special characters in your mysql / maria db password!

6
  • Well...I properly installed wp-cli and cv in my /local/usr/bin, added chomd +x so it will be executable then tried this command as the web user: '/opt/cpanel/ea-php73/root/usr/bin/php wp cv api job.process_mailing --user=admin --path=/home/the_website/the.subdomain.net/ Fatal error: Uncaught CRM_Core_Exception: [unauthorized: Authorization failed thrown in /home/the_website/the.subdomain.net/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php on line 232' ...but still get the error. I'm at a loss. Any other thoughts? The editor text on this site is wack Commented Jun 24, 2023 at 14:14
  • I'd try some basic commands wp cv sql-conf and wp cv cache-clear and see what that says. I'd also look at file permissions, and see that Directories are 755 and files are 644. I'd also call WP with full path Just in case.... This is from a cpanel server /opt/cpanel/ea-php74/root/usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --path=/home/example.org/public_html --timezone="America/New_York" civicrm api job.execute auth=0 Commented Jun 25, 2023 at 15:10
  • That snippet runs all scheduled jobs , for you I'd try /opt/cpanel/ea-php74/root/usr/bin/php /usr/local/bin/wp --user=civicron --url=https://example.org --path=/home/example.org/public_html --timezone="America/New_York" civicrm api job.process_mailing auth=0 Commented Jun 25, 2023 at 15:10
  • No go, same set of errors about the api authorization. I fiddled with the code you suggested like last time too all with the same error. I'm going to setup a brand new LAMP > restore from backup with sql dump and reinstall the plugin. I suspect it has something to do with CPanel, the user running the cron or who knows. Maybe I'll get different results on a stand alone host than a shared host. Thanks for pitching in and offering to assist. Commented Jun 26, 2023 at 13:09
  • Still pulling my hair out. Everything seems to be in the ~/civi.thewebsite.com/wp-content/uploads/civi/civicrm.settings.php and maybe the mysql connection string got mangled? The reason I think this is because the password to the db has "special characters" in it from the default WP install. ~?#. I noticed a password like this: 1~ab?3#4, gets turned into this: 1%1B%3%...or something like that. Like, its mangling special characters into % characters and messing with the case of the letter in once instance and adding some. Weird and odd. I tried to manually edit to no avail. Still trying Commented Jun 26, 2023 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.