WordPress.org

Ready to get started?Download WordPress

Forums

Quick Page/Post Redirect Plugin
[resolved] Error Importing File if No Existing Redirects (With Fix) (2 posts)

  1. llinde
    Member
    Posted 1 year ago #

    If no redirects exist in the system and you're trying to import a pipe-delimited text redirect file, the process dies with array_merge errors. The issue is that the quickppr_redirects and quickppr_redirects_meta options are empty, and PHP throws an error if you try to merge an array with, essentially, null.

    Here's the fix, at about line 1152 of page_post_redirect_plugin.php, the two array_merge calls need to check for an empty array. Here's the fix that I put in that fixed the issue:

    if(!empty($tempArr)){
      $currQRs = get_option('quickppr_redirects');
      if (!empty($currQRs)) {
       $resultQR = array_merge($currQRs, $tempArr);
      } else {
       $resultQR = $tempArr;
      }
      update_option('quickppr_redirects',$resultQR);
    }
    if(!empty($tempMArr)){
      $currQRM = get_option('quickppr_redirects_meta');
      if (!empty($currQRM)) {
        $resultQRM = array_merge($currQRM, $tempMArr);
      } else {
        $resultQRM = $tempMArr;
      }
      update_option('quickppr_redirects_meta',$resultQRM);
    }
    }

    http://wordpress.org/extend/plugins/quick-pagepost-redirect-plugin/

  2. prophecy2040
    Member
    Plugin Author

    Posted 1 year ago #

    @llinde -
    Thanks for providing a fix. This is basically what we did in the latest version (5.0.3) to fix the issue, with a slight variation.

    Basically we did this (same result, different approach):

    if(!empty($tempArr)){
      $temp = get_option('quickppr_redirects');
      $currQRs = ($temp !='' && is_array($temp)) ? $temp : array();
      $resultQR = array_merge($currQRs, $tempArr);
      update_option('quickppr_redirects',$resultQR);
    }
    if(!empty($tempMArr)){
      $temp = get_option('quickppr_redirects_meta');
      $currQRM = ($temp !='' && is_array($temp)) ? $temp : array();
      $resultQRM = array_merge($currQRM, $tempMArr);
      update_option('quickppr_redirects_meta',$resultQRM);
    }

    Thanks again for sharing your results!
    Warm regards,
    Don

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.