Support » Plugin: License Manager for WooCommerce » Internal Server Error

  • Resolved deve42

    (@deve42)


    Hi Drazen,

    Since upgrading to 2.1.0, I’m getting the following error when generating license:

    An error of type E_ERROR was caused in line 29 of the file /var/www/html/wp-content/plugins/license-manager-for-woocommerce/vendor/defuse/php-encryption/src/Crypto.php. Error message: Uncaught TypeError: Key expected for argument 2. String given instead. in /var/www/html/wp-content/plugins/license-manager-for-woocommerce/vendor/defuse/php-encryption/src/Crypto.php:29
    Stack trace:
    #0 /var/www/html/wp-content/plugins/license-manager-for-woocommerce/includes/Crypto.php(128): Defuse\Crypto\Crypto::encrypt(‘MTXP1N42HQUTWQG…’, ”)
    #1 /var/www/html/wp-includes/class-wp-hook.php(288): LicenseManagerForWooCommerce\Crypto->encrypt(‘MTXP1N42HQUTWQG…’)
    #2 /var/www/html/wp-includes/plugin.php(206): WP_Hook->apply_filters(‘MTXP1N42HQUTWQG…’, Array)
    #3 /var/www/html/wp-content/plugins/license-manager-for-woocommerce/includes/integrations/woocommerce/Controller.php(194): apply_filters(‘lmfwc_encrypt’, ‘MTXP1N42HQUTWQG…’)
    #4 /var/www/html/wp-includes/class-wp-hook.php(288): LicenseManagerForWooCommerce\Integrations\WooCommerce\Controller->insertGeneratedLicenseKeys(NULL, 1726, Array, 3, Object(LicenseManagerForWooCommerce\Models\Resources\Generator))
    #5 /var/www/html/wp-includes/plugin.php(206): WP

    Because I installed the beta plugin and had problem installing this latest version, I had to manually delete the plugin folder and the defuse/secret folder and recreated the API key and generators.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @deve42

    The problem seems to happen when a license key is being created via a generator, and then saved. It’s possibly related to the cryptographic secret files. Did you make a backup of those?

    Also, do you have a test environment where I could take a look myself? Its hard to tell the exact cause without some good ol’ debugging ๐Ÿ™‚

    Yes I backed up the two files and added them to wp-config.php. However, after the failed installation of the latest version (from the GitHub version), I manually deleted the settings in wp-config.php and removed all related folders and files (even checked the DB for orphan tables). So it was a clean install and I recreated generators but once I try to buy a product, checkout fails with “Internal Server Error”.

    Could it be php 7.3 which I installed?

    Plugin Author Drazen Bebic

    (@drazenbebic)

    @deve42,

    it could be, to be honest I haven’t tested it with PHP 7.3 yet. Could you try reverting to 7.2 and see if it still works?

    Reverted to 7.2 and it’s the same error:

    2019-11-14T20:43:48+00:00 CRITICAL Uncaught TypeError: Key expected for argument 2. String given instead. in /var/www/html/wp-content/plugins/license-manager-for-woocommerce/vendor/defuse/php-encryption/src/Crypto.php:29
    Stack trace:
    #0 /var/www/html/wp-content/plugins/license-manager-for-woocommerce/includes/Crypto.php(128): Defuse\Crypto\Crypto::encrypt(‘N6S2UXKNB47WACP…’, ”)
    #1 /var/www/html/wp-includes/class-wp-hook.php(288): LicenseManagerForWooCommerce\Crypto->encrypt(‘N6S2UXKNB47WACP…’)
    #2 /var/www/html/wp-includes/plugin.php(206): WP_Hook->apply_filters(‘N6S2UXKNB47WACP…’, Array)
    #3 /var/www/html/wp-content/plugins/license-manager-for-woocommerce/includes/integrations/woocommerce/Controller.php(194): apply_filters(‘lmfwc_encrypt’, ‘N6S2UXKNB47WACP…’)
    #4 /var/www/html/wp-includes/class-wp-hook.php(288): LicenseManagerForWooCommerce\Integrations\WooCommerce\Controller->insertGeneratedLicenseKeys(3152, 1726, Array, 1, Object(LicenseManagerForWooCommerce\Models\Resources\Generator))
    #5 /var/www/html/wp-includes/plugin.php(206): WP in /var/www/html/wp-content/plugins/license-manager-for-woocommerce/vendor/defuse/php-encryption/src/Crypto.php on line 29

    Plugin Author Drazen Bebic

    (@drazenbebic)

    @deve42

    I think that, for whatever reason, your cryptographic secrets (defuse and secret) aren’t being loaded properly. Can you try removing the variables from wp-config.php and putting the files back in the lmfwc-files folder to see if that fixes it?

    I put the files back and the error went away. However, there are two issues:

    1) I’m using character map ABCDEFGHJKLMNPQRSTUVWXYZ123456789, with 4 chunks of length 5 and a suffix in this format: -XW8QA

    The license generated is: PJZTPPJ7PJAJGACMCRXG-XW8QA

    It used to generate the correct format like this one: 8U7WC-JNLEL-5J56S-EL26L-DM8PT

    2) The license keys page in My-Account (/my-account/view-license-keys/) is not found (404)

    Any idea what’s going on?

    Plugin Author Drazen Bebic

    (@drazenbebic)

    The second part should be easy: Save your permalinks and it should work again.

    As for the generator, I am unsure. Have you tried deleting it and creating a new one?

    Yes Iโ€™ve deleted the generators a few times and recreated them. Changed the character map as well but itโ€™s still generating licenses without the dashes.

    • This reply was modified 3 weeks, 2 days ago by deve42.
    Plugin Author Drazen Bebic

    (@drazenbebic)

    @deve42,

    I don’t think we’ll make much more progress like this. Do you have a test/staging environment where I could log in and take a look myself?

    Ok I got it fixed by adding a dash into the Separator field. Didn’t have to do this before as it is optional and the dash is default. I’ll test it more and see if everything is working.

    Thanks for your help again, Drazen!

    Plugin Author Drazen Bebic

    (@drazenbebic)

    @deve42,

    no problem, glad that I could at least solve part of your problem ๐Ÿ™‚

    So I set up a brand new test server with PHP 7.2 and it’s generating the same license without the dashes if I don’t add it manually in the Separator field.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    Hello @deve42

    Yes, that is correct and it should have always been so.

    In the 2.1 update I have updated the PHP class in charge of generating license keys. This class was a corner stone of the plugin, and coded very early on. A lot of functionality is based on it, so I have been reluctant to rework and refactor that class. The rework was necessary because it the coding wasn’t up to standard.

    I have finally done this in the 2.1 update, and one major change was the removal of default generator values. If a generator didn’t have a separator, it would use a dash. This was unintentional and undesired behavior. Separators should only be used if they are explicitly defined, otherwise the chunks will just be connected without a separator.

    deve42

    (@deve42)

    I see, thanks for clarifying. It would help if this breaking change is mentioned in the release notes.

    Plugin Author Drazen Bebic

    (@drazenbebic)

    @deve42,

    Actually, I don’t know why I didn’t think of that myself. I will update the release notes accordingly, thank you.

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.