Skip to content

Commit

Permalink
Merge pull request #938 from matomo-org/develop
Browse files Browse the repository at this point in the history
Update live for upcoming 4.15.3 release
  • Loading branch information
diosmosis authored Nov 5, 2023
2 parents 9edcaf0 + 274e767 commit 8f08c3d
Show file tree
Hide file tree
Showing 55 changed files with 13,862 additions and 381 deletions.
10 changes: 10 additions & 0 deletions .env.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PHP_VERSION=8.1
WP_DB_HOST=mariadb
WP_ADMIN_USER=root
[email protected]
WOOCOMMERCE_PIWIK_ANALYTICS=./empty
PORT=3000
PAGER=more
BACKEND=mariadb
MULTISITE=0
WOOCOMMERCE=1
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ karma.conf.js export-ignore
.DS_Store export-ignore
.editorconfig export-ignore
docker-compose.yml export-ignore
tsconfig.json export-ignore
wdio.conf.ts export-ignore
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Matomo Release Action
#
#
# Required GitHub secrets:
#
#
# RELEASE_PASSWORD | password that needs to be provided to start the action
# GITHUB_TOKEN | github release token to publish
# SVN_USERNAME | the svn username to publish a new plugin release
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
script: |
core.setFailed('Release password didn\'t match.')
- name: "Check if user is allowed"
if: ${{ github.actor != 'mattab' && github.actor != 'tsteur' && github.actor != 'mattmary' && github.actor != 'justinvelluppillai' && github.actor != 'lance-matomo' }}
if: ${{ github.actor != 'mattab' && github.actor != 'tsteur' && github.actor != 'mattmary' && github.actor != 'justinvelluppillai' && github.actor != 'lance-matomo' && github.actor != 'diosmosis' }}
uses: actions/github-script@v3
with:
script: |
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
echo "A tag for $tag_exists already exists."
exit 1
fi
echo "version=$version" >> $GITHUB_ENV
- name: "Create release"
uses: ncipollo/release-action@c4bf6c1ab090090498fb7f3ddc9f99ba5ab619b9
Expand All @@ -91,6 +91,6 @@ jobs:
cd scripts
./deploy.sh $version ${{ secrets.SVN_USERNAME }} "${{ secrets.SVN_PASSWORD }}"
cd ..
echo "update=false" >> $GITHUB_OUTPUT
shell: bash
77 changes: 74 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ permissions:
repository-projects: none
security-events: none
statuses: none
id-token: write # for docker gha cache

concurrency:
group: php-${{ github.ref }}
Expand All @@ -39,7 +40,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wp-versions: [ 'latest', 'trunk' ]
wp-versions: [ 'latest' ]
php-versions: [ '7.2', '7.3', '7.4', '8.0' ]
include:
- wp-versions: '5.2'
Expand Down Expand Up @@ -100,6 +101,78 @@ jobs:
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && WP_MULTISITE=1 ./vendor/bin/phpunit

e2e_tests:
runs-on: 'ubuntu-22.04'
strategy:
fail-fast: false
matrix:
wp-versions: [ 'latest', 'trunk' ]
php-versions: [ '7.2', '8.1' ]
permissions:
contents: read # <--- allows to read repo
steps:
- uses: actions/checkout@v3
with:
lfs: true
persist-credentials: false

# setup xvfb
- run: sudo apt-get update && sudo apt-get install -y xvfb x11-xserver-utils xauth

# setup firefox
- uses: browser-actions/setup-firefox@v1
- run: firefox --version

# setup node
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: '**/package-lock.json'
- run: npm install

# docker-compose up
- run: ls ${{ github.workspace }}/scripts
- run: pwd
# TODO: i can't seem to get docker layer caching to work.
- run: |
export ACTIONS_CACHE_URL=$(echo "$ACTIONS_ID_TOKEN_REQUEST_URL" | grep -Po 'https://[^/]+/[^/]+/' | sed 's/pipelines/artifactcache/')
export ACTIONS_RUNTIME_TOKEN=$ACTIONS_ID_TOKEN_REQUEST_TOKEN
docker buildx build --cache-to type=gha --cache-from type=gha --build-arg PHP_VERSION=${{ matrix.php-versions }} --build-context project="${{ github.workspace }}/scripts" --file=scripts/Dockerfile.local scripts
env:
PHP_VERSION: ${{ matrix.php-versions }}
WOOCOMMERCE: 1
WORDPRESS_FOLDER: test
RESET_DATABASE: 1
WORDPRESS_VERSION: ${{ matrix.wp-versions }}
- run: |
cat > .env <<EOF
PHP_VERSION=$PHP_VERSION
WOOCOMMERCE=1
WORDPRESS_FOLDER=test
RESET_DATABASE=1
WORDPRESS_VERSION=$WORDPRESS_VERSION
EOF
env:
PHP_VERSION: ${{ matrix.php-versions }}
WORDPRESS_VERSION: ${{ matrix.wp-versions }}
- run: docker compose --env-file .env.default --env-file .env up -d wordpress
- run: sleep 60 # wait for docker-compose launch to finish

# run tests
- run: xvfb-run --auto-servernum npm run wdio
env:
PHP_VERSION: ${{ matrix.php-versions }}
WOOCOMMERCE: 1
WORDPRESS_FOLDER: test
RESET_DATABASE: 1
WORDPRESS_VERSION: ${{ matrix.wp-versions }}

# output docker-compose logs
- run: npm run compose logs wordpress --no-color
- run: npm run compose stop

checkstyle:
runs-on: 'ubuntu-20.04'
steps:
Expand Down Expand Up @@ -137,5 +210,3 @@ jobs:
- name: Run checkstyle
shell: bash
run: cd ${{ github.workspace }}/wp-content/plugins/matomo && ./vendor/bin/phpcs


4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
.*~
*~
.idea/
/empty/
/node_modules/*
!/node_modules/chart.js

# for local docker dev
docker
.env

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
== Changelog ===

= 4.15.3 =
* Compatibility with WooCommerce's HPOS feature
* Avoid executing System Report on every Matomo for WordPress admin page view
* Show Ninja Firewall notification as a row in the system report as opposed to a warning that cannot be dismissed
* Attempt to track WooCommerce orders when order status changes from pending to processing in case customers never visit the order confirmation page
* Better detection of WooCommerce orders that were created manually through the WordPress back office
* Fix Tag Manager errors caused by missing file in 4.15.1 release
* Add a new advanced setting for disabling async archiving without having to modify wp-config.php
* Add a success notification when manually triggered archiving via the Troubleshooting menu succeeds
* Add new system report check that checks that the bots.yml file is not accessible
* Use new name for related WordPress plugin 'Connect Matomo'

= 4.15.2 =
* Fix ecommerce reports not archiving if no goal conversions or order for the site
* Provide more context when an API request fails token authentication
Expand Down
5 changes: 2 additions & 3 deletions LEGALNOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ CREDITS

For detailed contribution history, refer to the source, tickets,
patches, and Git revision history, available at
https://github.com/matomo-org/wp-matomo/issues
https://github.com/matomo-org/wp-matomo
https://github.com/matomo-org/matomo-for-wordpress/issues
https://github.com/matomo-org/matomo-for-wordpress


SEPARATELY LICENSED COMPONENTS AND LIBRARIES
Expand All @@ -47,4 +47,3 @@ THIRD-PARTY CONTENT
License: The MIT License (MIT) see node_modules/chart.js/LICENSE.md

For more third party content see the list in `app/LEGALNOTICE`.

49 changes: 41 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

A hassle-free and cost-free web analytics platform for your WordPress which lets you stay in full control with 100% data ownership and user-privacy protection.

This plugin installs a fully functional [Matomo](https://matomo.org) within your WordPress. If you already have a working Matomo (either [On-Premise](https://matomo.org/matomo-on-premise/) or [Matomo Cloud](https://matomo.org/hosting/)), use the [WP-Matomo Integration plugin](https://wordpress.org/plugins/wp-piwik/) instead. If you have a high traffic website, we recommend using On-Premise or the Cloud-hosted solution for better performance.
This plugin installs a fully functional [Matomo](https://matomo.org) within your WordPress. If you already have a working Matomo (either [On-Premise](https://matomo.org/matomo-on-premise/) or [Matomo Cloud](https://matomo.org/hosting/)), use the [Connect Matomo Integration plugin](https://wordpress.org/plugins/wp-piwik/) instead. If you have a high traffic website, we recommend using On-Premise or the Cloud-hosted solution for better performance.

Learn more about this plugin in the [readme.txt](readme.txt).

Expand Down Expand Up @@ -42,19 +42,19 @@ composer install # or composer.phar install

#### Local environment through docker

If you have docker and docker-compose installed, you can setup a local development environment with a single command:
If you have docker and docker compose installed, you can setup a local development environment with a single command:

```bash
docker-compose up wordpress; docker-compose stop
npm run compose up wordpress; npm run compose stop
```

The first time the container starts it will compile php extensions within the container it needs, download wordpress
and set it up.

After starting the container, visit `https://localhost:3000/` to see the list of available wordpress versions.
Pick one, and it will take you to the Wordpress installer.
After starting the container, visit `http://localhost:3000/` to see the list of available wordpress versions.
Pick one, and it will take you to Wordpress.

After installing Wordpress, go to the plugins page and activate Matomo for Wordpress.
Go to wp-login.php, then enter `root` for the user name and `pass` for the password and login.

Note: docker related files, such as the downloaded wordpress and database files, will be stored in a new folder named `./docker`. As long
as you are using this local dev environment, you should not delete this folder.
Expand All @@ -71,22 +71,55 @@ variables are supported:
- `WP_PLUGINS` - a list of plugin/version pairs like "my-plugin my-other-plugin:1.2.3". For each item, wp-cli will attempt to download and activate the plugin.
This is the same format as the Active Plugins entry in the System Report, so you could copy that value to this environment variable to quickly (or more quickly)
replicate a user's setup.
- `WP_ADMIN_USER` - the admin wordpress username, defaults to 'root'. This variable is only used when installing wordpress. It shouldn't be changed afterwards, unless doing a fresh install.
- `WP_ADMIN_EMAIL` - the admin user's email, defaults to '[email protected]'. This variable is only used when installing wordpress. It shouldn't be changed afterwards, unless doing a fresh install.
- `WOOCOMMERCE` - if set, installs and sets up woocommerce. This includes setting up a payment gateway with stripe and adding some test products. (Note: you will still have to go through woocommerce
onboarding as there is no way to disable it, and that means you will have to enter your stripe test keys manually when setting up the payment gateway.)

**Running wp-cli**

Make sure the wordpress service is running in one terminal, then in another terminal run:

```bash
npm run compose run wp -- <... rest of command ...>
```

**Running matomo console**

Make sure the wordpress service is running in one terminal, then in another terminal run:

```bash
npm run compose run console -- <... rest of command ...>
```

**Testing on nginx**

To run the local dev environment with nginx instead of apache, first make sure there is a `127.0.0.1 nginx` entry in your `/etc/hosts` file.

Then run the following command:

```bash
npm run compose up nginx fpm; npm run compose stop
```

Finally visit `http://nginx:3000/`.

Note: you cannot have both the apache and nginx services running simultaneously as they will try to use the same port.

**Accessing MariaDB/MySQL**

First ensure the database you want to inspect (mariadb or mysql) is the one that's currently being used by your local
environment. Then, while the local environment is running in one shell, open another and run the command:

```bash
docker-compose run mariadb mariadb -h mariadb -u root -p
npm run compose run mariadb mariadb -h mariadb -u root -p
```

Enter `pass` for the password.

(For mysql, replace instances of "mariadb" in the command with "mysql".)

## Security

Security is a top priority at Matomo. As potential issues are discovered, we validate, patch and release fixes as quickly as we can. We have a security bug bounty program in place that rewards researchers for finding security issues and disclosing them to us.

[Learn more](https://matomo.org/security/) or check out our [HackerOne program](https://hackerone.com/matomo).
Expand Down
2 changes: 1 addition & 1 deletion app/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function matomo_log_message_no_display($message)
}

if ( $GLOBALS['MATOMO_LOADED_DIRECTLY'] ) {
// see https://github.com/matomo-org/wp-matomo/issues/190
// see https://github.com/matomo-org/matomo-for-wordpress/issues/190
// wp-external-links plugin would register an ob_start(function () {...}) and manipulate any of our API output
// and in some cases the output would get completely lost causing blank pages.
add_filter('wpel_apply_settings', '__return_false', 99999);
Expand Down
33 changes: 31 additions & 2 deletions assets/js/asset_manager_core_js.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions classes/WpMatomo.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class WpMatomo {
public static $settings;

public function __construct() {
$this->declare_woocommerce_hpos_compatible();

if ( ! $this->check_compatibility() ) {
return;
}
Expand Down Expand Up @@ -245,4 +247,15 @@ public function init_plugin() {
do_action( 'matomo_ecommerce_init', $tracker );
}
}

private function declare_woocommerce_hpos_compatible() {
add_action(
'before_woocommerce_init',
function() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', 'matomo/matomo.php', true );
}
}
);
}
}
2 changes: 1 addition & 1 deletion classes/WpMatomo/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private function execute_request( $api_method, $with_idsite, $params ) {

Bootstrap::do_bootstrap();

// refs https://github.com/matomo-org/wp-matomo/issues/370 ensuring segment will be used from default request when
// refs https://github.com/matomo-org/matomo-for-wordpress/issues/370 ensuring segment will be used from default request when
// creating new request object and not the encoded segment
if ( isset( $params['segment'] ) ) {
if ( isset( $_GET['segment'] ) || isset( $_POST['segment'] ) ) {
Expand Down
19 changes: 12 additions & 7 deletions classes/WpMatomo/Admin/AdvancedSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace WpMatomo\Admin;

use Piwik\CliMulti\Process;
use Piwik\IP;
use WpMatomo\Bootstrap;
use WpMatomo\Capabilities;
Expand Down Expand Up @@ -68,8 +69,10 @@ public function show_settings() {
}

Bootstrap::do_bootstrap();
$matomo_detected_ip = IP::getIpFromHeader();
$matomo_delete_all_data = $this->settings->should_delete_all_data_on_uninstall();
$matomo_detected_ip = IP::getIpFromHeader();
$matomo_delete_all_data = $this->settings->should_delete_all_data_on_uninstall();
$matomo_disable_async_archiving = $this->settings->is_async_archiving_disabled_by_option();
$matomo_async_archiving_supported = $this->settings->is_async_archiving_supported();

include dirname( __FILE__ ) . '/views/advanced_settings.php';
}
Expand All @@ -93,14 +96,16 @@ public function can_user_manage() {
}

private function apply_settings() {
$changes = [
Settings::DISABLE_ASYNC_ARCHIVING_OPTION_NAME => ! empty( $_POST['matomo']['disable_async_archiving'] ),
];

if ( ! defined( 'MATOMO_REMOVE_ALL_DATA' ) ) {
$this->settings->apply_changes(
[
Settings::DELETE_ALL_DATA_ON_UNINSTALL => ! empty( $_POST['matomo']['delete_all_data'] ),
]
);
$changes[ Settings::DELETE_ALL_DATA_ON_UNINSTALL ] = ! empty( $_POST['matomo']['delete_all_data'] );
}

$this->settings->apply_changes( $changes );

$client_headers = [];
if ( ! empty( $_POST[ self::FORM_NAME ]['proxy_client_header'] ) ) {
$client_header = sanitize_text_field( wp_unslash( $_POST[ self::FORM_NAME ]['proxy_client_header'] ) );
Expand Down
Loading

0 comments on commit 8f08c3d

Please sign in to comment.