Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent fatals with the Howto block in rare situations #21332

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Back to intval, since we dont accept floats anyway
  • Loading branch information
Djennez committed Apr 23, 2024
commit 9cbac04d73a451063b04156c278886d515db9073
6 changes: 3 additions & 3 deletions src/generators/schema/howto.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Renders a list of questions, referencing them by ID.
*
* @return array Our Schema graph.

Check failure on line 24 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@return annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::generate() does not specify type hint for items of its traversable return value.

Check failure on line 24 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@return annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::generate() does not specify type hint for items of its traversable return value.
*/
public function generate() {
$graph = [];
Expand All @@ -36,8 +36,8 @@
/**
* Adds the duration of the task to the Schema.
*
* @param array $data Our How-To schema data.

Check failure on line 39 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@param annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::add_duration() does not specify type hint for items of its traversable parameter $data.

Check failure on line 39 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@param annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::add_duration() does not specify type hint for items of its traversable parameter $data.
* @param array $attributes The block data attributes.

Check failure on line 40 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@param annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::add_duration() does not specify type hint for items of its traversable parameter $attributes.

Check failure on line 40 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@param annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::add_duration() does not specify type hint for items of its traversable parameter $attributes.
*
* @return void
*/
Expand All @@ -46,9 +46,9 @@
return;
}

$days = ! is_numeric( $attributes['days'] ) ? 0 : floatval( $attributes['days'] );
$hours = ! is_numeric( $attributes['hours'] ) ? 0 : floatval( $attributes['hours'] );
$minutes = ! is_numeric( $attributes['minutes'] ) ? 0 : floatval( $attributes['minutes'] );
$days = ! is_numeric( $attributes['days'] ) ? 0 : intval( $attributes['days'] );

Check failure on line 49 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function is_numeric() should be referenced via a fully qualified name.

Check failure on line 49 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function intval() should be referenced via a fully qualified name.

Check failure on line 49 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function is_numeric() should be referenced via a fully qualified name.

Check failure on line 49 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function intval() should be referenced via a fully qualified name.
$hours = ! is_numeric( $attributes['hours'] ) ? 0 : intval( $attributes['hours'] );

Check failure on line 50 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function is_numeric() should be referenced via a fully qualified name.

Check failure on line 50 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function intval() should be referenced via a fully qualified name.

Check failure on line 50 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function is_numeric() should be referenced via a fully qualified name.

Check failure on line 50 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function intval() should be referenced via a fully qualified name.
$minutes = ! is_numeric( $attributes['minutes'] ) ? 0 : intval( $attributes['minutes'] );

Check failure on line 51 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function is_numeric() should be referenced via a fully qualified name.

Check failure on line 51 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function intval() should be referenced via a fully qualified name.

Check failure on line 51 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function is_numeric() should be referenced via a fully qualified name.

Check failure on line 51 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

Function intval() should be referenced via a fully qualified name.

if ( ( $days + $hours + $minutes ) > 0 ) {
$data['totalTime'] = \esc_attr( 'P' . $days . 'DT' . $hours . 'H' . $minutes . 'M' );
Expand All @@ -58,7 +58,7 @@
/**
* Adds the steps to our How-To output.
*
* @param array $data Our How-To schema data.

Check failure on line 61 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@param annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::add_steps() does not specify type hint for items of its traversable parameter $data.

Check failure on line 61 in src/generators/schema/howto.php

View workflow job for this annotation

GitHub Actions / Check code style

@param annotation of method \Yoast\WP\SEO\Generators\Schema\HowTo::add_steps() does not specify type hint for items of its traversable parameter $data.
* @param array $steps Our How-To block's steps.
*
* @return void
Expand Down
Loading