-
Notifications
You must be signed in to change notification settings - Fork 384
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
Fatal error due to admin bar disabled #6189
Comments
I'm not able to reproduce the error due to the the admin bar being hidden. Nevertheless, your PHP code to hide the admin bar should be modified as follows: add_filter( 'show_admin_bar', function( $show ) {
if ( ! is_admin() ) {
$show = false;
}
return $show;
} ); The error seems unrelated to the admin bar being shown. At issue is this code here:
Apparently for you one stylesheet has a diff --git a/includes/validation/class-amp-validated-url-post-type.php b/includes/validation/class-amp-validated-url-post-type.php
index 2e0ad95e2..f51332c6c 100644
--- a/includes/validation/class-amp-validated-url-post-type.php
+++ b/includes/validation/class-amp-validated-url-post-type.php
@@ -2539,11 +2539,16 @@ static function ( $a, $b ) use ( $stylesheets ) {
</td>
<td class="column-percentage">
<?php
- $percentage = $stylesheet['final_size'] / ( $included_final_size + $excluded_final_size );
+ $denominator = ( $included_final_size + $excluded_final_size );
?>
- <meter value="<?php echo esc_attr( $stylesheet['final_size'] ); ?>" min="0" max="<?php echo esc_attr( $included_final_size + $excluded_final_size ); ?>" title="<?php esc_attr_e( 'Stylesheet bytes of total CSS added to page', 'amp' ); ?>">
- <?php echo esc_html( round( ( $percentage ) * 100 ) ) . '%'; ?>
- </meter>
+ <?php if ( $denominator > 0 ) : ?>
+ <?php $percentage = $stylesheet['final_size'] / $denominator; ?>
+ <meter value="<?php echo esc_attr( $stylesheet['final_size'] ); ?>" min="0" max="<?php echo esc_attr( $included_final_size + $excluded_final_size ); ?>" title="<?php esc_attr_e( 'Stylesheet bytes of total CSS added to page', 'amp' ); ?>">
+ <?php echo esc_html( round( ( $percentage ) * 100 ) ) . '%'; ?>
+ </meter>
+ <?php else : ?>
+ included/excluded final sizes are zero
+ <?php endif; ?>
</td>
<td class="column-priority">
<?php echo esc_html( $stylesheet['priority'] ); ?> |
@amarinediary Did you find the cause of the problem? |
Yes sorry, indeed, apparently not properly hiding the admin bar was trouble shooting with the amp plugin. You did answer that question perfectly, and I feel ashamed for opening it ! |
Bug Description
Hiding the Wordpress admin bar via the
show_admin_bar
hook filter will result in a fatal error. on the AMP Validated URL screen on Recheck user action.Expected Behaviour
Using recheck shouldn't return a fatal error when the admin bar isn't displayed;
Steps to reproduce
function.php
3 .Go to the AMP Validated URL page and click Recheck
4. See error
Screenshots
Additional context
5.7.1
2.1.1
8.0
Additional information
All plugins disabled. Fresh WordPress install and blank theme. Site health passed.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation brief
QA testing instructions
Demo
Changelog entry
The text was updated successfully, but these errors were encountered: