Title: Missing check for empty causes PHP Deprecated errors
Last modified: October 21, 2025

---

# Missing check for empty causes PHP Deprecated errors

 *  Resolved [ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [7 months, 3 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/)
 * Getting PHP Deprecated errors for empty `$wpdb->esc_like()` in `debug.log`:
 *     ```wp-block-code
       #0 ..wp-content/plugins/pretty-link/pro/app/models/PlpKeyword.php(282): wpdb->esc_like(NULL)#1 ..wp-content/plugins/pretty-link/pro/app/models/PlpKeyword.php(240): PlpKeyword->getKeywordToLinksArray(XXX)#2 ..wp-content/plugins/pretty-link/pro/app/controllers/PlpKeywordsController.php(211): PlpKeyword->get_post_keywords_lookup(XXX)[21-Oct-2025 13:18:34 UTC] PHP Deprecated:  addcslashes(): Passing null to parameter #1 ($string) of type string is deprecated in ../wp-includes/class-wpdb.php on line 1784
       ```
   
 * This happes if `parse_url()` in file `pro/app/models/PlpKeyword.php:281` returns
   empty
 *     ```wp-block-code
       $post_url_path = parse_url(get_permalink($post_id), PHP_URL_PATH);
       ```
   
 * and is still used for `esc_like()` in next line:
 *     ```wp-block-code
       $post_url_path = '%' . $wpdb->esc_like($post_url_path);
       ```
   
 * Suggestion: Check `$post_url_path` for empty before further use.
 * PrettyLinks 3.6.17, WordPress 6.6.4, PHP 8.2.x

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Support [oiler](https://wordpress.org/support/users/eulerarthur/)
 * (@eulerarthur)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18693486)
 * Hi there,
   Thank you for this report!To help us fully understand and reproduce
   this issue, could you share what steps you followed when you encountered this
   warning? For example:
 * – what were you doing when the log was generated? (e.g., creating/editing a post,
   saving a draft, using auto-save, etc.)
   – what post type were you working with?–
   do you have keyword replacement enabled, and if so, for which post types?– what
   permalink structure does your site use?
 * Regardless, we’ll be reviewing the code in pro/app/models/PlpKeyword.php to investigate
   the issue and see what can be done to prevent this deprecation warning in PHP
   8.2+. This thread will be updated once we have more information.
   Thank you,
 *  Thread Starter [ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18694384)
 * The error seems to be triggered if
    - any visitor in frontend visits
    - a taxonomy archive (both `post_tag` and `category`) page
    - and if the first shown entry
    - has a `Target URL` pointing to external site
    - without any further path
 *     ```wp-block-code
       Target URL like this: https://www.example.com
       ```
   
 * Post type: `post`
 * Keyword Replacements is enabled, for `post`, `page` and a custom post type
 * Permalink structure: `/%category%/%postname%/`
 *  Thread Starter [ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18695086)
 * Additional observation, error also triggered on
    - date archive page, like `/2025/04/`
    - and in general also on paged archive pages like `/tag/abc/page/4/` or `/2025/
      04/page/3/` etc.
 *  Plugin Support [oiler](https://wordpress.org/support/users/eulerarthur/)
 * (@eulerarthur)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18698115)
 * Hi there,
 * Thanks for the details!
 * I’ll be better checking this matter in the next hours. You can expect a response
   by the end of the day.
 * Appreciate your patience in the meantime.
 * Best regards,
 *  Plugin Support [oiler](https://wordpress.org/support/users/eulerarthur/)
 * (@eulerarthur)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18699020)
 * Hello there,
 * Thanks again for the additional details. We are still reviewing this issue but
   haven’t reached a conclusion yet. I’ll need a bit more time to properly investigate
   and test the scenarios you’ve described. I’ll follow up with more information
   tomorrow.
 * Thanks for your patience.
 * Best regards,
 *  Plugin Support [oiler](https://wordpress.org/support/users/eulerarthur/)
 * (@eulerarthur)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18700455)
 * Hey [@ov3rfly](https://wordpress.org/support/users/ov3rfly/),
 * Thanks for your patience!
 * I’ve been testing the scenarios you described but haven’t been able to reproduce
   the deprecation warning in a clean environment, which suggests it’s related to
   something specific in your site’s configuration. However, we’ve created a fix
   that adds a null check before the value is passed to $wpdb->esc_like(), which
   should prevent the deprecation warning you’re seeing.
 * Could you test this fix on your site and let us know if it resolves the issue?**
   Please make sure to have a website backup before testing it**. Then, in pro/app/
   models/PlpKeyword.php, replace lines 281-283:
 *     ```wp-block-code
       $post_url_path = parse_url(get_permalink($post_id), PHP_URL_PATH);$post_url_path = '%' . $wpdb->esc_like($post_url_path);$and_str = $wpdb->prepare("AND li.url NOT LIKE %s", $post_url_path);$post_url_path = parse_url(get_permalink($post_id), PHP_URL_PATH);$post_url_path = '%' . $wpdb->esc_like($post_url_path);$and_str = $wpdb->prepare("AND li.url NOT LIKE %s", $post_url_path);
       ```
   
 * with:
 *     ```wp-block-code
       $post_url_path = parse_url(get_permalink($post_id), PHP_URL_PATH);if($post_url_path !== null) {  $post_url_path = '%' . $wpdb->esc_like($post_url_path);  $and_str = $wpdb->prepare("AND li.url NOT LIKE %s", $post_url_path);} else {  $and_str = '';}$post_url_path = parse_url(get_permalink($post_id), PHP_URL_PATH);if($post_url_path !== null) {  $post_url_path = '%' . $wpdb->esc_like($post_url_path);  $and_str = $wpdb->prepare("AND li.url NOT LIKE %s", $post_url_path);} else {  $and_str = '';}
       ```
   
 * This should be included in the next plugin update. Also ensure to have a backup
   copy of this file before testing it, and kindly let us know if this resolves 
   the warnings on your site.
   Thanks,
 *  Thread Starter [ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [7 months, 2 weeks ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18700532)
 * Thanks for the feedback. Your code seems a bit messed up with that extra last
   line but I got the idea and added a `$post_url_path !== null` check and it now
   seems to catch the above cases and does not call empty `$wpdb->esc_like()` any
   more.
 * As a sidenote, I do not really understand the whole function yet as e.g. a Target
   URL like this `https://www.example.com/` (note the training slash) creates a `'%'.
   $wpdb->esc_like('/')` for the `$and_str` and compares `li.url` to be not like
   that, not sure if that case makes sense.
 *  Plugin Support [oiler](https://wordpress.org/support/users/eulerarthur/)
 * (@eulerarthur)
 * [7 months, 1 week ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18702832)
 * Hi [@ov3rfly](https://wordpress.org/support/users/ov3rfly/),
 * Regarding your sidenote about the trailing slash case – you’re right to point
   out the logic, but in practice it works correctly. We’ve tested this on clean
   installs with various permalink structures (including plain permalinks where 
   post paths are just `/`), and keyword replacement functions properly on archives,
   single posts, and homepages.
 * The code is designed to prevent self-referencing links by excluding Pretty Links
   whose target URLs match the current post’s path. While the logic with `NOT LIKE'%/'`
   might seem too broad when the path is `/`, WordPress’s permalink handling and
   the way the function is called ensures keywords still get replaced correctly.
 * And sorry about that extra duplicated line at the end of my code snippet – the
   WordPress.org forums sometimes mangle code block formatting!
 * Thanks again for the detailed report and for testing the fix!
 * Best regards,
 *  Thread Starter [ov3rfly](https://wordpress.org/support/users/ov3rfly/)
 * (@ov3rfly)
 * [7 months, 1 week ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18703357)
 * Appears to be fixed with PrettyLinks 3.6.18, thanks for quick response.
 *  Plugin Support [oiler](https://wordpress.org/support/users/eulerarthur/)
 * (@eulerarthur)
 * [7 months, 1 week ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18704894)
 * Hey there,
 * Glad that it is fine now!
 * In this case, I hope we are good to close here, but please feel free to contact
   us anytime if you need assistance with our products.
 * Kind regards,

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Missing check for empty causes PHP Deprecated errors’ is closed to new
replies.

 * ![](https://ps.w.org/pretty-link/assets/icon-256x256.png?rev=2503434)
 * [PrettyLinks - Affiliate Links, Link Branding, Link Tracking, Marketing and Stripe Payments Plugin](https://wordpress.org/plugins/pretty-link/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pretty-link/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pretty-link/)
 * [Active Topics](https://wordpress.org/support/plugin/pretty-link/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pretty-link/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pretty-link/reviews/)

## Tags

 * [empty](https://wordpress.org/support/topic-tag/empty/)
 * [parse_url](https://wordpress.org/support/topic-tag/parse_url/)
 * [PHP Deprecated](https://wordpress.org/support/topic-tag/php-deprecated/)

 * 10 replies
 * 2 participants
 * Last reply from: [oiler](https://wordpress.org/support/users/eulerarthur/)
 * Last activity: [7 months, 1 week ago](https://wordpress.org/support/topic/missing-check-for-empty-causes/#post-18704894)
 * Status: resolved