Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"PHP message: PHP Notice: Undefined variable: port in /admin-bar-user-switching/functions/abus-core-functions.php on line 14 #13

Open
geraldurbas opened this issue Nov 25, 2021 · 1 comment

Comments

@geraldurbas
Copy link

geraldurbas commented Nov 25, 2021

Hi
Get a Warning - nothing dramatic just ugly in the logs!
Seen on PHP FPM 7.4 served by NGINX (maybe related - saw that port looks 4 Server variables

Seems to be in the released file, avaliable trough WP. The Version in master tree seems to work fine
-> pls release soon

@EarthmanWeb
Copy link

It appears that this is fixed on the Master branch, but has not yet been deployed to the WP repo:

<?php

defined('ABSPATH') || exit;

/**
 * Determine the URL of the currently viewed page - will return array if $parse set to true.
 *
 * @see https://github.com/scottsweb/null/blob/master/functions.php
 *
 * @return string|array
 */
function abus_get_current_url($parse = false )
{
    $s = empty( $_SERVER[ 'HTTPS' ] ) || ( $_SERVER[ 'HTTPS' ] != 'on' ) ? '' : 's';
    $protocol = substr( strtolower( $_SERVER[ 'SERVER_PROTOCOL' ] ), 0, strpos( strtolower( $_SERVER[ 'SERVER_PROTOCOL' ] ), '/' ) ) . $s;
    $port = ( $_SERVER[ 'SERVER_PORT' ] == '80') ? '' : ( ":".$_SERVER[ 'SERVER_PORT' ] );

    if ( $parse ) {
        return parse_url( $protocol . "://" . $_SERVER[ 'HTTP_HOST' ] . $port . $_SERVER[ 'REQUEST_URI' ] );
    }

    return apply_filters('abus_get_current_url', $protocol . "://" . $_SERVER[ 'HTTP_HOST' ] . $port . $_SERVER[ 'REQUEST_URI' ]);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants