• Resolved unostar

    (@unostar)


    Hey, some random web developer here.

    Have some (hopefully) useful fixes for your Woocommerce PDF Watermark plugin.

    While doing tasks for my clients I came across some issues:

    Environment: Nginx 1.22.1 / PHP 7.4.33 (FPM-FastCGI) / OpenSSL 3.0.2

    ——

    Major issue: result PDF is an empty file, no issues in error_log.?

    SOLUTION:

    This was harder to track, as there are no references of an error in log or elsewhere.

    End of a day, after debugging online server, I found one piece of code which silently died returning false on all requests:

    /wp-content/plugins/woocommerce-pdf-watermark/includes/lib/fpdi/FpdiProtection.php on line 502:

      protected function arcfour( $key, $data) {
            return openssl_encrypt($data, 'RC4-40', $key, OPENSSL_RAW_DATA, '');
        }

    You version of FpdiProtection.php is 2.0.0, while the actual 2.0.3 (https://github.com/Setasign/fpdi-protection/releases/tag/v2.0.3) has this ?bug? noted (https://github.com/Setasign/fpdi-protection/blob/master/src/FpdiProtection.php#L210):

    OpenSSL with RC4 supported is required. In case you use OpenSSL 3 make sure that legacy providers are loaded (see https://wiki.openssl.org/index.php/OpenSSL_3.0#Providers).

    ——

    Minor issue: temporary files not removed, PHP warning in error_log.

    PHP Warning:? unlink(…): No such file or directory in /wp-content/plugins/woocommerce-pdf-watermark/includes/class-wc-pdf-watermark.php on line 635

    SOLUTION:

    line 635:

    public function cleanup_files() {
    	if ( ! empty( $this->stamped_file ) ) {
    		session_write_close();
    		if (stristr( getenv( 'SERVER_SOFTWARE' ), 'nginx' )) fastcgi_finish_request();
    		sleep(5); // lame, but some race conditions occur rarely
    		array_map( 'unlink', $this->stamped_file );
    		$this->stamped_file = [];
    	}
    } // End cleanup_files()

    line 606:

    // Set the stamped file so we can delete it via shutdown hook.
    $this->stamped_file[] = realpath($new_file);

    ——

    Hopefully you can check this and apply in future releases.

    Thanks, have a nice day!

    ——

    P.S. just a small note on X-Accel-Redirect / XSendfile:

    • with Nginx, make sure fastcgi_ignore_headers is not blocking X-Accel-Redirect;
    • to work correctly, the further rules processing should be stopped with ^~
    location ^~ /wp-content/uploads/woocommerce_uploads {
    	if ( $upstream_http_x_accel_redirect = "" ) {
            return 403;
        }
        internal;
    }

Viewing 1 replies (of 1 total)
  • Hi @unostar

    Thanks for reaching out!

    I understand that you’ve encountered an issue with our premium plugin WooCommerce PDF Watermark and you’ve also shared your workaround that hopefully would be added to the next release, correct?

    Firstly, thank you for sharing your solution with the community. Since this is a premium plugin, the proper channel to air your concern is either thru submitting a support request or raising it as a feature request here so that our developers could check on your issue further.

    I will be marking this thread as resolved since your concern would be best handled by our Happiness Engineers there.

    Thanks!

Viewing 1 replies (of 1 total)
  • The topic ‘Woocommerce PDF Watermark’ is closed to new replies.