MindblownHQ / wooping-shop-health

The WooCommerce Shop Health plugin by Wooping
https://wooping.io
2 stars 1 forks source link

Fatal error upon install #2

Open alx359 opened 3 days ago

alx359 commented 3 days ago

Got your post on reddit and just installed (via zip) in localwp (W10) onto a mirror copy of a fully-fledged Woo shop. Doesn't work for me, when I hit Wooping > Shop Health. The shop works fine.

`[13-Nov-2024 04:12:42 UTC] PHP Notice: The plugin metadata file does not contain the required 'name' and/or 'version' keys. in D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\yahnis-elsts\plugin-update-checker\Puc\v5p5\Metadata.php on line 56 [13-Nov-2024 04:13:07 UTC] PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it in D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connectors\Connector.php:70 Stack trace:

0 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connectors\Connector.php(70): PDO->__construct('mysql:host=loca...', 'root', 'root', Array)

1 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connectors\Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=loca...', 'root', 'root', Array)

2 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connectors\MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=loca...', Array, Array)

3 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connectors\ConnectionFactory.php(184): Illuminate\Database\Connectors\MySqlConnector->connect(Array)

4 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors{closure}()

5 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connection.php(1064): call_user_func(Object(Closure))

6 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connection.php(1100): Illuminate\Database\Connection->getPdo()

7 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connection.php(442): Illuminate\Database\Connection->getReadPdo()

8 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connection.php(368): Illuminate\Database\Connection->getPdoForSelect(true)

9 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connection.php(705): Illuminate\Database\Connection->Illuminate\Database{closure}('select avg(`sco...', Array)

10 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connection.php(672): Illuminate\Database\Connection->runQueryCallback('select avg(`sco...', Array, Object(Closure))

11 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connection.php(376): Illuminate\Database\Connection->run('select avg(`sco...', Array, Object(Closure))

12 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Query\Builder.php(2414): Illuminate\Database\Connection->select('select avg(`sco...', Array, true)

13 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Query\Builder.php(2402): Illuminate\Database\Query\Builder->runSelect()

14 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Query\Builder.php(2936): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}()

15 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Query\Builder.php(2403): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))

16 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Query\Builder.php(2863): Illuminate\Database\Query\Builder->get(Array)

17 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Query\Builder.php(2837): Illuminate\Database\Query\Builder->aggregate('avg', Array)

18 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Eloquent\Builder.php(1657): Illuminate\Database\Query\Builder->avg('score')

19 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\src\Helpers\ScoreCalculator.php(18): Illuminate\Database\Eloquent\Builder->__call('avg', Array)

20 D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\src\Controllers\Dashboard\Dashboard.php(30): Wooping\ShopHealth\Helpers\ScoreCalculator->settings()

21 D:\localwp\domain.com\app\public\wp-includes\class-wp-hook.php(324): Wooping\ShopHealth\Controllers\Dashboard\Dashboard->display('')

22 D:\localwp\domain.com\app\public\wp-includes\class-wp-hook.php(348): WP_Hook->apply_filters('', Array)

23 D:\localwp\domain.com\app\public\wp-includes\plugin.php(517): WP_Hook->do_action(Array)

24 D:\localwp\domain.com\app\public\wp-admin\admin.php(259): do_action('toplevel_page_w...')

25 {main}`

PHP: 8.0.30 MariaDB 10.4.32 Apache WP 6.6.2

lucprincen commented 3 days ago

Thanks for reporting this @alx359. The issue was caused on the update-server; this now has been patched, so this shouldn't happen anymore.

That being said; I'm leaving this bug report open for now, because we should add a gracefull fallback if no update can be found. Tagging this for the hotfix later this week.

alx359 commented 3 days ago

I reloaded Wooping > Shop Health but the same error is still happening. Do I have to wait for a plugin update now?

PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it in D:\localwp\domain.com\app\public\wp-content\plugins\wooping-shop-health\vendor\illuminate\database\Connectors\Connector.php:70

lucprincen commented 3 days ago

This is a different error, and It looks like our custom tables aren't getting found in your database. Would you might sharing the DB_CHARSET and DB_COLLATE in your wp-config file?

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', 'utf8_general_ci' );
alx359 commented 3 days ago
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

Thanks.

lucprincen commented 3 days ago

Is your database running on the same machine? Or is it remote?

alx359 commented 3 days ago

Same machine, localwp.

lucprincen commented 3 days ago

Really strange. Sorry for the inconvenience. I'm going to have to dive a bit deeper into this and spin it into it's own issue. I'll let you know once we find it. Thanks for helping out and reporting it!

alx359 commented 3 days ago

Thanks for looking into this.

lucprincen commented 3 days ago

It seems to be an issue with LocalWP. This is not going to be an overnight fix, but I'll make sure we get support for LocalWP shipped ASAP :)

mklasen commented 1 day ago

LocalWP runs separate MySQL instance for each site and connect to those via socket files on Linux and macOS or port numbers in Windows.

In Shop Health, we're creating our own database connection based on the the defines set in wp-config.php. In WordPress, the database host and port are combined in the DB_HOST field, with for example localhost:3306.

We, however, setup the connection with separate host and port fields.

I think the solution (at least for Windows) is to:

  1. Explode the DB_HOST define by :
  2. Pass the exploded strings for host and port in $capsule->addConnection

We should also confirm compatibility with database sockets, we can spin up a Linux docker environment and install LocalWP to see if any issues pop up

lucprincen commented 1 day ago

Thanks for looking into this. Would you mind picking this up @mklasen ? I'll spin that into a new issue.

I've left this issue open to gracefully deal with losing a connection with the Wooping.io API if an update-check fails (the initial issue reported by @alx359 )