• Using v3.3.4 which has just been published.
    In filesystem.php line 17, $scheme gives a string variable type on my site. So $uploadPath is not set at line 25 leading to undefined variable notices for lines 32 and 33. Perhaps these few lines could be visited before the next update.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Nextendweb

    (@nextendweb)

    Hi @lorro,
    thank you for the feedback! Could you open that file again and send me the the var_dump($wp_upload_dir);? That would help a lot!

        public function __construct() {
            $this->_basepath    = realpath(WP_CONTENT_DIR);
            $this->_librarypath = str_replace($this->_basepath, '', N2LIBRARY);
    
            $this->paths[] = $this->_basepath;
    
            $wp_upload_dir = wp_upload_dir();
            var_dump($wp_upload_dir);
    
            $scheme        = parse_url($wp_upload_dir['basedir'], PHP_URL_SCHEME);
    Plugin Author Nextendweb

    (@nextendweb)

    Hi @lorro,
    I think I found the issue. Could you try to open filesystem.php and replace the __construct method with the following:

        public function __construct() {
            $this->_basepath    = realpath(WP_CONTENT_DIR);
            $this->_librarypath = str_replace($this->_basepath, '', N2LIBRARY);
    
            $this->paths[] = $this->_basepath;
    
            $wp_upload_dir = wp_upload_dir();
            $scheme        = parse_url($wp_upload_dir['basedir'], PHP_URL_SCHEME);
    
            /**
             * Amazon S3 storage has s3://my-bucket/uploads upload path. If we found a scheme in the path we will
             * skip the realpath check so it won't fail in the future.
             * @url https://github.com/humanmade/S3-Uploads
             */
            if (!in_array($scheme, array('s3'))) {
                $uploadPath = rtrim(realpath($wp_upload_dir['basedir']), "/\\");
                if (empty($uploadPath)) {
                    echo 'Error: Your upload path is not valid or does not exist: ' . $wp_upload_dir['basedir'];
                    $uploadPath = rtrim($wp_upload_dir['basedir'], "/\\");
                }
            } else {
                $uploadPath = $wp_upload_dir['basedir'];
            }
    
            if (strpos($this->_basepath, $uploadPath) !== 0) {
                $this->paths[] = $uploadPath;
            }
    
            self::measurePermission(N2Platform::getPublicDir());
        }

    Does it solve the issue?

    Thread Starter Majeed Raza

    (@lorro)

    Sure. I use something like var_dump which does not show front end. I have redacted my domain name.

    [18-Jul-2018 06:20:02 UTC] Array
    (
        [path] => C:\Inetpub\vhosts\domain.com\httpdocs/wp-content/uploads/2018/07
        [url] => https://www.domain.com/wp-content/uploads/2018/07
        [subdir] => /2018/07
        [basedir] => C:\Inetpub\vhosts\domain.com\httpdocs/wp-content/uploads
        [baseurl] => https://www.domain.com/wp-content/uploads
        [error] => 
    )

    $scheme gives the string: C

    Thread Starter Majeed Raza

    (@lorro)

    Yes, the revised__construct function does not give the undefined variable message. Thank you.

    Plugin Author Nextendweb

    (@nextendweb)

    I thank you for the report, @lorro. We will release this bugfix today with a new version.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Undefined variable $uploadPath’ is closed to new replies.