Skip to content

#1560 Fix - Membership thank you page leaking another member's account details #2705

#1560 Fix - Membership thank you page leaking another member's account details

#1560 Fix - Membership thank you page leaking another member's account details #2705

Workflow file for this run

name: Run code sniff on PR
on: pull_request
jobs:
test:
name: Code sniff (PHP 7.4, WP Latest)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 100
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer, cs2pr
- name: Tool versions
run: |
php --version
composer --version
- name: Get cached composer directories
uses: actions/cache@v3
with:
path: ./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
- name: Setup and install composer
run: composer install
- name: Get changed PHP files
id: changed
run: |
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD -- '*.php' > changed-php.txt || true
if [ -s changed-php.txt ]; then
echo "count=$(wc -l < changed-php.txt)" >> $GITHUB_OUTPUT
echo "Files to sniff:"
cat changed-php.txt
else
echo "count=0" >> $GITHUB_OUTPUT
echo "No PHP files changed in this PR"
fi
- name: Run code sniff
if: steps.changed.outputs.count != '0'
continue-on-error: true
run: |
./vendor/bin/phpcs --report=checkstyle --report-file=./phpcs-report.xml -s -p --file-list=changed-php.txt || true
- name: Run code sniff (no PHP changes)
if: steps.changed.outputs.count == '0'
run: echo "Skipping PHPCS - no PHP files changed."
- name: Show PHPCS results in PR (annotations)
if: steps.changed.outputs.count != '0' && hashFiles('./phpcs-report.xml') != ''
run: cs2pr ./phpcs-report.xml
- name: Generate PHPCS comment body
if: steps.changed.outputs.count != '0' && hashFiles('./phpcs-report.xml') != ''
id: phpcs_comment
run: |
node -e "
const fs = require('fs');
const xml = fs.readFileSync('phpcs-report.xml', 'utf8');
const fileBlocks = xml.match(/<file[^>]*name=\"([^\"]+)\"[^>]*>([\\s\\S]*?)<\\/file>/g) || [];
let md = '## PHPCS results\\n\\n';
let total = 0;
const rows = [];
fileBlocks.forEach(block => {
const nameMatch = block.match(/name=\"([^\"]+)\"/);
const file = nameMatch ? nameMatch[1].replace(/^.*\//, '') : '';
const errors = block.match(/<error[^>]*>/g) || [];
errors.forEach(tag => {
const line = (tag.match(/line=\"([^\"]+)\"/) || [])[1] || '';
const sev = (tag.match(/severity=\"([^\"]+)\"/) || [])[1] || '';
let msg = (tag.match(/message=\"([^\"]*)\"/) || [])[1] || '';
msg = msg.replace(/\|/g, '\\\\|').replace(/\n/g, ' ');
const source = (tag.match(/source=\"([^\"]+)\"/) || [])[1] || '';
rows.push({ file, line, sev, msg, source });
total++;
});
});
if (total === 0) {
md += '✅ No PHPCS issues found.';
} else {
md += '| File | Line | Severity | Message |\\n|------|------|----------|---------|\\n';
rows.slice(0, 100).forEach(r => { md += '| ' + r.file + ' | ' + r.line + ' | ' + r.sev + ' | ' + r.msg.substring(0, 80) + (r.msg.length > 80 ? '…' : '') + ' |\\n'; });
if (rows.length > 100) md += '\\n*… and ' + (rows.length - 100) + ' more (see annotations).*';
}
fs.writeFileSync('phpcs-comment.md', md);
"
- name: Comment PHPCS results on PR
if: steps.changed.outputs.count != '0' && hashFiles('./phpcs-report.xml') != ''
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: phpcs-report
issue-number: ${{ github.event.pull_request.number }}
body-path: phpcs-comment.md
edit-mode: replace