ahmedkaludi / check-email

3 stars 3 forks source link

PHP Fatal error #101

Closed Sdaud1950 closed 1 week ago

Sdaud1950 commented 3 weeks ago

Call to undefined function ck_mail_insert_error_logs

Ref Ticket:https://magazine3.in/conversation/303870?folder_id=29

jcvanhalle-ec commented 3 weeks ago

So far it prevents activation (haven't checked out if it prevents logging or has any other effects) but I think it's only a problem when activating with wp-cli (see fix):

wp plugin activate check-email --path=/var/www/example.com/www --url=https://foo.example.com
Fatal error: Uncaught Error: Call to undefined function CheckEmail\Core\DB\ck_mail_create_error_logs() in /var/www/example.com/www/wp-content/plugins/check-email/include/Core/DB/Check_Email_Table_Manager.php:60
Stack trace:
#0 /var/www/example.com/www/wp-includes/class-wp-hook.php(324): CheckEmail\Core\DB\Check_Email_Table_Manager->on_activate()
#1 /var/www/example.com/www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#2 /var/www/example.com/www/wp-includes/plugin.php(517): WP_Hook->do_action()
#3 /var/www/example.com/www/wp-admin/includes/plugin.php(703): do_action()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/extension-command/src/Plugin_Command.php(333): activate_plugin()
#5 [internal function]: Plugin_Command->activate()
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(100): call_user_func()
#7 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}()
#8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(491): call_user_f in /var/www/example.com/www/wp-content/plugins/check-email/include/Core/DB/Check_Email_Table_Manager.php on line 60

Apache2, php-fpm 7.4

There's a work-around https://github.com/wp-cli/wp-cli/issues/984

wp plugin activate check-email
  --require=/tmp/make-admin.php
  --path=/var/www/example.com/www
  --url=https://foo.example.com

with file /tmp/make-admin.php:

<?php
define( 'WP_ADMIN', true );

Super dirty temporary fix, in check-mail.php (edit: don't do that :D):

 45 if ( is_admin() ) {
 46 
 47     require_once(CK_MAIL_PATH. "/include/helper-function.php" );
 48     require_once(CK_MAIL_PATH. "/include/class-check-email-newsletter.php" );
 49     require_once(CK_MAIL_PATH. "/include/Check_Email_SMTP_Tab.php" );
 50 } else {
 51     require_once(CK_MAIL_PATH. "/include/helper-function.php" ); // 
 52 }
shanemac10 commented 3 weeks ago

Thanks guys for working on it. The client confirmed this morning that they did not experience the "Fatal error" message this time when they logged back in this morning, which they would normally see on the first attempt. My quick fix was to do a function_exists check before calling ck_mail_insert_error_logs in .../check-email/include/Core/Check_Email_Logger.php, like so...

if(function_exists('ck_mail_insert_error_logs')) ck_mail_insert_error_logs($data_to_insert);

As a note on the above if-else solution, I would say you might move the... require_once(CK_MAIL_PATH. "/include/helper-function.php" ); out of the if statement entirely if you are including it both conditions. To keep it DRY and less cluttered.

jcvanhalle-ec commented 3 weeks ago

As a note on the above if-else solution, I would say you might move the... require_once(CK_MAIL_PATH. "/include/helper-function.php" ); out of the if statement entirely if you are including it both conditions. To keep it DRY and less cluttered.

Oh yeah, totally right ! It is a quick-and-dirty edit (with temporary meaning 5 seconds, the time it takes to fire the wp-cli command and check if it activates) to check if the plugin would activate if the file is always required but it was in the early hours and my brain did... something.

edit: Also found it this https://github.com/wp-cli/wp-cli/pull/5581 which brings the --context option to wp-cli so this should work:

wp plugin activate check-email
  --context=admin
  --path=/var/www/example.com/www
  --url=https://foo.example.com
Sdaud1950 commented 3 weeks ago

Another user : https://magazine3.in/conversation/304273?folder_id=29

Error

PHP Fatal error: Uncaught Error: Call to undefined function CheckEmail\Core\ck_mail_forward_mail() in /home/wp-content/plugins/check-email/include/Core/Check_Email_Logger.php:97

MohammedAkramU7 commented 2 weeks ago

Another user: https://magazine3.in/conversation/305487?folder_id=21

Sdaud1950 commented 2 weeks ago

Another user: https://magazine3.in/conversation/306447?folder_id=29

MohammedAkramU7 commented 1 week ago

Another User: https://magazine3.in/conversation/307228?folder_id=21

Sanjeevsetu commented 1 week ago

Hi @jcvanhalle-ec & @shanemac10

We have released a new version 2.0.1 with this ticket's fix. Could you please update the plugin and lets know whether fixed or not?

jcvanhalle-ec commented 1 week ago

@Sanjeevsetu: seems okay to me, no more error when activating (with and without --context). Thanks :).

Sanjeevsetu commented 1 week ago

@jcvanhalle-ec

Thanks for the confirmation. I am closing this ticket.