Skip to content

Commit 8b8042a

Browse files
committed
Merge branch 'develop' into fix/wrapped-embeds-in-p-tags
2 parents c719d1c + 4d88938 commit 8b8042a

15 files changed

+14811
-10537
lines changed

.github/workflows/build-test-measure.yml

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,36 @@ jobs:
156156
repo-token: '${{ secrets.GITHUB_TOKEN }}'
157157
report-json: 'lint-js-report.json'
158158

159+
#-----------------------------------------------------------------------------------------------------------------------
160+
161+
normalize-composer:
162+
name: 'Normalize composer.json'
163+
needs: pre-run
164+
if: needs.pre-run.outputs.changed-php-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
165+
runs-on: ubuntu-latest
166+
steps:
167+
- name: Checkout
168+
uses: actions/checkout@v3
169+
170+
- name: Setup PHP
171+
uses: shivammathur/setup-php@v2
172+
with:
173+
php-version: '8.1'
174+
coverage: none
175+
176+
- name: Get composer-normalize.phar
177+
run: |
178+
wget https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar
179+
chmod +x composer-normalize.phar
180+
181+
- name: Validate composer.json
182+
run: composer --no-interaction validate --no-check-all
183+
184+
- name: Normalize composer.json
185+
run: |
186+
composer config --no-interaction --no-plugins allow-plugins.ergebnis/composer-normalize true
187+
./composer-normalize.phar --dry-run
188+
159189
#-----------------------------------------------------------------------------------------------------------------------
160190

161191
lint-php:
@@ -189,18 +219,9 @@ jobs:
189219
- name: Install Composer dependencies
190220
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction
191221

192-
- name: Validate composer.json
193-
run: composer --no-interaction validate --no-check-all
194-
195222
- name: Detect coding standard violations (PHPCS)
196223
run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings
197224

198-
- name: Normalize composer.json
199-
run: |
200-
composer config --no-interaction --no-plugins allow-plugins.ergebnis/composer-normalize true
201-
composer require --no-interaction --dev ergebnis/composer-normalize --ignore-platform-reqs
202-
composer --no-interaction normalize --dry-run
203-
204225
#-----------------------------------------------------------------------------------------------------------------------
205226

206227
static-analysis-php:
@@ -362,12 +383,13 @@ jobs:
362383
mysql:
363384
image: mariadb:latest
364385
env:
365-
MYSQL_ALLOW_EMPTY_PASSWORD: true
366-
MYSQL_ROOT_PASSWORD:
367-
MYSQL_DATABASE: wordpress_test
386+
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
387+
MARIADB_DATABASE: wordpress_test
388+
MARIADB_MYSQL_LOCALHOST_USER: 1
389+
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
368390
ports:
369391
- 3306
370-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
392+
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
371393
continue-on-error: ${{ matrix.experimental == true }}
372394
strategy:
373395
fail-fast: false
@@ -606,12 +628,13 @@ jobs:
606628
mysql:
607629
image: mariadb:latest
608630
env:
609-
MYSQL_ALLOW_EMPTY_PASSWORD: true
610-
MYSQL_ROOT_PASSWORD:
611-
MYSQL_DATABASE: wordpress_test
631+
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
632+
MARIADB_DATABASE: wordpress_test
633+
MARIADB_MYSQL_LOCALHOST_USER: 1
634+
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
612635
ports:
613636
- 3306
614-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
637+
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
615638
continue-on-error: ${{ matrix.experimental == true }}
616639
strategy:
617640
fail-fast: false

assets/src/components/nav-menu/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export function NavMenu({ links = [], onClick }) {
2121
return (
2222
<Selectable ElementName="nav" className="nav-menu">
2323
<ul className="nav-menu__list">
24-
{links.map((link) => (
25-
<li key={link.url} className="nav-menu__item">
24+
{links.map((link, index) => (
25+
<li key={`${link.url}-${index}`} className="nav-menu__item">
2626
<a
2727
className={classnames('nav-menu__link', {
2828
'nav-menu__link--active': link.isActive,

assets/src/components/nav-menu/test/nav-menu.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,24 @@ describe('NavMenu', () => {
6060
const handler = jest.fn();
6161

6262
const { container } = render(
63-
<NavMenu links={links} onClick={handler} />
63+
// Pass empty URLs to avoid `Error: Not implemented: navigation (except hash changes)` in tests.
64+
// This is due to the JSDOM limitation to not support navigation.
65+
// Since we're not testing onClick event and not testing navigation, we can safely pass empty URLs.
66+
<NavMenu
67+
links={[
68+
{
69+
url: '',
70+
label: 'Foo',
71+
isActive: false,
72+
},
73+
{
74+
url: '',
75+
label: 'Bar',
76+
isActive: true,
77+
},
78+
]}
79+
onClick={handler}
80+
/>
6481
);
6582

6683
fireEvent.click(container.querySelector('a'));
@@ -69,6 +86,10 @@ describe('NavMenu', () => {
6986

7087
const [event, link] = handler.mock.calls[0];
7188
expect(event.type).toBe('click');
72-
expect(link).toBe(links[0]);
89+
expect(link).toStrictEqual({
90+
url: '',
91+
label: 'Foo',
92+
isActive: false,
93+
});
7394
});
7495
});

bin/ci/install-wp-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ install_db() {
135135
fi
136136

137137
# create database
138-
mysqladmin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS""$EXTRA"
138+
mariadb-admin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA || \
139+
mysqladmin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS"$EXTRA
139140
}
140141

141142
install_wp

includes/embeds/class-amp-core-block-handler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ private function process_text_widgets( Document $dom ) {
569569
foreach ( $dom->xpath->query( '//div[ @class = "textwidget" ]' ) as $text_widget ) {
570570
// Restore the width/height attributes which were preserved in preserve_widget_text_element_dimensions.
571571
foreach ( $dom->xpath->query( sprintf( './/*[ @%s or @%s ]', self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME, self::AMP_PRESERVED_HEIGHT_ATTRIBUTE_NAME ), $text_widget ) as $element ) {
572+
/** @var DOMElement $element */
572573
if ( $element->hasAttribute( self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME ) ) {
573574
$element->setAttribute( Attribute::WIDTH, $element->getAttribute( self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME ) );
574575
$element->removeAttribute( self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME );
@@ -586,6 +587,7 @@ private function process_text_widgets( Document $dom ) {
586587
* responsive so this is built-in. Note also the style rule for .wp-video in amp-default.css.
587588
*/
588589
foreach ( $dom->xpath->query( './/div[ @class = "wp-video" and @style ]', $text_widget ) as $element ) {
590+
/** @var DOMElement $element */
589591
$element->removeAttribute( 'style' );
590592
}
591593
}

includes/embeds/class-amp-tumblr-embed-handler.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public function sanitize_raw_embeds( Document $dom ) {
8686
);
8787
$overflow_element->textContent = __( 'See more', 'amp' );
8888
$amp_element->appendChild( $overflow_element );
89+
90+
/** @var DOMElement $placeholder */
8991
$placeholder->setAttribute( Attribute::PLACEHOLDER, '' );
9092
$amp_element->appendChild( $placeholder );
9193

includes/sanitizers/class-amp-style-sanitizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,7 @@ public function sanitize() {
10171017
}
10181018
} else {
10191019
foreach ( $styled_elements as $element ) {
1020+
/** @var DOMElement $element */
10201021
$attr = $element->getAttributeNode( Attribute::STYLE );
10211022
if ( $attr && preg_match( '/!\s*important/i', $attr->value ) ) {
10221023
ValidationExemption::mark_node_as_px_verified( $attr );

0 commit comments

Comments
 (0)