Custom Permalinks
PHP Error Undefined variable 'path' (5 posts)

  1. jetlej
    Posted 3 years ago #

    I'm getting roughly 20 of these erros on every page (with debug turned on) :

    Undefined index: path in /wp-content/plugins/custom-permalinks/custom-permalinks.php on line 261

    This doesn't affect functionality as far as I can see but I thought I'd report it anyways


  2. jonathan.pottervilla
    Posted 3 years ago #

    I ran into this issue today. It looks like the issue is with the output of the parse_URL path.

    Here's the modified code I used to fix the errors:

    Lines 96 & 97 become:

    $url = parse_url(get_bloginfo('wpurl'), PHP_URL_PATH);
    $request = ltrim(substr($_SERVER['REQUEST_URI'], strlen($url)),'/');

    Lines 154 & 155:

    $url = parse_url(get_bloginfo('url'), PHP_URL_PATH);
    $request = ltrim(substr($_SERVER['REQUEST_URI'], strlen($url)),'/');

    Lines 260 & 261:

    $url = parse_url(get_bloginfo('url'), PHP_URL_PATH);
    $request = ltrim(substr($string, strlen($url)),'/');

    Line 266:
    return ($string{0} == '/' ? '/' : '') . trailingslashit($url) . $_CPRegisteredURL;

    The changes are just in syntax, parsing just the path with PHP_URL_PATH rather than parsing the whole path, and calling $url['path'], which wasn't getting defined.

    - Jonathan

  3. jglovier
    Posted 3 years ago #

    Just installed the plugin today, also seeing the same issue with these Notices.

    Thanks for the fix Jonathan. Hoping the plugin gets an update soon.

  4. Steven
    Posted 3 years ago #

    Yep, those "undefined index" messages are annoying when debugging is turned on BUT I would like to point out that this one needs more urgent attention:

    Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.

  5. Eric Mann
    Posted 2 years ago #

    I actually fixed this bug to use the plugin for a client. You can find my "fixed" version on GitHub: https://github.com/ericmann/custom-permalinks/tree/dev

    I've also sent the changes back to the original developer via email but have yet to hear back. I'll pull in the latest release (that fixed a minor compatibility issue elsewhere) when I get the chance to the GitHub version is up to date.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Permalinks
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic