• Resolved Robert Trevellyan

    (@trevellyan)


    This is happening on a site that uses CloudFlare, has DISABLE_WP_CRON set, and instead uses a server cron job. The first time it happened was after I updated to WooCommerce version 3.4.0. At that time I saw from the WC status page that WC was looking for a different geolocation database (GeoLite2-Country.mmdb instead of GeoIP.dat/GeoIPv6.dat), which I duly uploaded to wp-content/uploads. The error went away.

    Now that I’ve updated to WooCommerce 3.4.1, the error is back. Here’s the full error report:

    PHP Fatal error:  Uncaught Error: Class 'PharData' not found in /REDACTED/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php:269
    Stack trace:
    #0 /REDACTED/wp-includes/class-wp-hook.php(286): WC_Geolocation::update_database()
    #1 /REDACTED/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array)
    #2 /REDACTED/trevellyan.biz/wp-includes/plugin.php(515): WP_Hook->do_action(Array)
    #3 /REDACTED/wp-cron.php(126): do_action_ref_array('woocommerce_geo...', Array)
    #4 {main}
      thrown in /REDACTED/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php on line 269

    This is what the cron job looks like:
    cd $HOME/REDACTED && /usr/local/bin/php-7.0 wp-cron.php

Viewing 15 replies - 1 through 15 (of 15 total)
  • dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hey @trevellyan

    I’ve seen this error before and it was related to a Windows server
    https://github.com/woocommerce/woocommerce/issues/19742

    This issue could be due to Cloudflare but may not be – are you able to spin up a new site on the same server without Cloudflare?

    For the GeoLocation can you try this “trick”, please?

    Go to WooCommerce Settings, change the location to “Do not geolocate” save the settings, then go back and change to Geolocate, then save again.

    See if that helps things.

    Thanks,

    Thread Starter Robert Trevellyan

    (@trevellyan)

    The site is running on DreamPress, so I can’t spin up an other copy on the same server. I could clone it somewhere else, if you think that might shed any light.

    Anyway, after a couple of cron job runs reported the error described above, there have been no more cron error reports since yesterday (the job runs hourly).

    But I went ahead and changed the “Default customer location” setting “No location by default”, and saved it. Then I tried setting it back to Geolocate, and got a 500 error. Fortunately, when I refreshed the page, the setting reverted to “No location”. Then I tried “Geolocate (with page caching support)” and got another 500 error, and the setting reverted again when I refreshed.

    With WP_DEBUG defined, the reported error is:
    Fatal error: Uncaught Error: Class 'PharData' not found in /REDACTED/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php:269 Stack trace: #0 /REDACTED/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php(126): WC_Geolocation::update_database() #1 /REDACTED/wp-includes/class-wp-hook.php(288): WC_Geolocation::maybe_update_database('geolocation', '') #2 /REDACTED/wp-includes/plugin.php(203): WP_Hook->apply_filters('geolocation', Array) #3 /REDACTED/wp-includes/option.php(312): apply_filters('pre_update_opti...', 'geolocation', '', 'woocommerce_def...') #4 /REDACTED/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-settings.php(845): update_option('woocommerce_def...', 'geolocation', 'yes') #5 /REDACTED/wp-content/plugins/woocommerce/includes/admin/settings/class-wc-settings-general.php(378): WC_Admin_Settings::save_fields(Array) #6 /REDACTED in /REDACTED/wp-content/plugins/woocommerce/includes/class-wc-geolocation.php on line 269

    The Apache error log is empty.

    Secondary question: what is the difference between those two Geolocate settings?

    Thomas Shellberg

    (@shellbeezy)

    Automattic Happiness Engineer

    Your PHP version might be quite old(you should be running at least 5.6+, preferably 7.0+). Or, your PHP install might not have PharData installed:

    https://stackoverflow.com/questions/7847013/class-phardata-not-found

    From the WooCommerce settings documention:

    Geolocate address verifies where the customer’s current location and calculates taxes accordingly.
    Geolocate with page caching support is the same as above, but does the geolocation via Ajax. You may notice your website URLs have a ?v=xxxxx appended to them. This is normal to prevent static caching of prices.

    Thread Starter Robert Trevellyan

    (@trevellyan)

    PHP version is 7.0.30. I’ll check with DreamHost regarding installation of PharData.

    Thread Starter Robert Trevellyan

    (@trevellyan)

    Here’s the response from DreamHost:

    ===================================================
    Phar is installed by default, but is not enabled by default. To enable it for your domain you can add this to your .user.ini (or phprc) file:
    extension = phar.so
    ===================================================

    I went with a .user.ini, since that will work across php versions, and so far, so good (I was at least able to save the WooCommerce settings with Geolocate enabled).

    Should we lobby DreamHost to enable Phar by default? Seems like it might be a common problem.

    Thomas Shellberg

    (@shellbeezy)

    Automattic Happiness Engineer

    @trevellyan – After rebooting the server, are you seeing that the error goes away? It’s hard to say, all hosts tend to run their services a bit differently, and some hosts(particularly shared hosts) tend to restrict PHP Modules in order to err on the safer side.

    Thread Starter Robert Trevellyan

    (@trevellyan)

    DreamPress is a premium, VPS-based, WordPress-optimized hosting service, so I would expect different considerations to apply vs basic shared hosting.

    Anyway, the error has not occurred again. Thanks for your help.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    I work for DreamPress, so I’ll take this up with the team today!

    Thread Starter Robert Trevellyan

    (@trevellyan)

    Thanks Mika @ipstenu, I have a ticket open in the DreamHost system for the domain trevellyan.biz.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    I made an internal ticket to get the work done and add this for everyone ??

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Aaand we’ll be done with that this week, so going forward, everyone will have phar working.

    Thomas Shellberg

    (@shellbeezy)

    Automattic Happiness Engineer

    Awesome work here @ipstenu ??

    Thread Starter Robert Trevellyan

    (@trevellyan)

    Thanks again Mika!

    I cannot tell you how happy I was to find this. I was trying to figure out why my state was changing when Angeleye’s (excellent) Paypal Express plugin was changing the state when passed back from Paypal. It was fine on all my local environments, but breaking on the production dreamhost VPS. I had been troubleshooting this on and off for 2 weeks. THANK YOU!

    Just FYI for anyone still having this problem. Check your PHP version with Dreampress. Legacy DreamPress still uses PHP 5.6 and phar isn’t enabled/working. You need to upgrade your PHP to 7+. To upgrade DreamPress PHP you need to contact support, you can’t do it yourself.

    Hopefully this will save people some time.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘PHP Fatal error Class ‘PharData’ not found in class-wc-geolocation.php:269’ is closed to new replies.