Debugging SMTP connection in Thunderbird

Had to debug the SMTP connection to WebSupport SMTP server, because even the login data was correct the connection failed.

To enable SMTP logs go to Settings > General, scroll to bottom and click Config Editor…

In the config editor search for mailnews.smtp.loglevel and set it from Warn to All

To see logs go to Tools > Developer Tools > Error Console

Thunderbird debug log level for SMTP
Thunderbird debug log level for SMTP

Issue was that I had enabled GeoIP protection for my mailbox.

PHP profiling/debugging with Xdebug and Webgrind

  1. Install Xdebug
  2. cd /var/www/ (where your web servers document root is set)
  3. git clone https://github.com/jokkedk/webgrind

More info at https://github.com/jokkedk/webgrind/wiki/Installation

Webgrind call graph
Webgrind call graph

Connect to localhost MySQL from Docker container

To test connection to MySQL/MariaDB server running on localhost from Docker container try:

docker run --rm -it --net=host mariadb mysql -u root -h 127.0.0.1
--rm  Automatically remove the container when it exits https://docs.docker.com/engine/reference/run/#clean-up-rm
-i    Keep STDIN open even if not attached https://docs.docker.com/engine/reference/run/#foreground
-t    Allocate a pseudo-TTY
--net Connect a container to a network https://docs.docker.com/engine/reference/run/#network-settings

Debugging duplicate query exec in WordPress

During debugging a plugin malfunction I had duplicate option update SQL queries and after som thinking I came up with the following debug line to catch the trace of duplicate function call:

 error_log(var_export(debug_backtrace(), true));

I placed it above the return line in update_option() function in wp-includes/option.php

Finally had a trace in php/apache error_log file.

The second query came from an action hook in another plugin 😦

Compiling Xdebug for PHP

While I’m not sticking to Arch Linux’s PHP (it’s version 7 by default a long time) so I had to compile Xdebug for my PHP version. Great thing at xdebug’s site is that they provide a wizard which parses the pasted php.ini and outputs an install instruction list 🙂

For me the following worked like charm:

  1. Download xdebug-2.4.0.tgz
  2. Unpack the downloaded file with tar -xvzf xdebug-2.4.0.tgz
  3. Run: cd xdebug-2.4.0
  4. Run: phpize (See the FAQ if you don’t have phpize).As part of its output it should show:
    Configuring for:
    PHP Api Version:         20131106
    Zend Module Api No:      20131226
    Zend Extension Api No:   220131226
    

    If it does not, you are using the wrong phpize. Please follow
    this FAQ entry and skip the next step.

  5. Run: ./configure
  6. Run: make
  7. Run: cp modules/xdebug.so /usr/lib/php/modules
  8. Edit /etc/php/php.ini and add the line
    zend_extension = /usr/lib/php/modules/xdebug.so
  9. sudo systemctl restart httpd.service

Oh yeah
Xdebug 2.4