tachyon-plugin icon indicating copy to clipboard operation
tachyon-plugin copied to clipboard

Undefined variable notices in inc/class-tachyon.php on line 363

Open peterwilsoncc opened this issue 6 years ago • 4 comments

I'm receiving a lot of undefined variables notices when using WP 5.3.2 with Tachyon, it caused by the compact( ... 'size' ) variable in the tachyon_post_image_args hook.

[21-Dec-2019 10:47:54 UTC] PHP Notice:  compact(): Undefined variable: size in /chassis/vendor/humanmade/tachyon-plugin/inc/class-tachyon.php on line 363
[21-Dec-2019 10:47:54 UTC] PHP Stack trace:
[21-Dec-2019 10:47:54 UTC] PHP   1. {main}() /chassis/index.php:0
[21-Dec-2019 10:47:54 UTC] PHP   2. require() /chassis/index.php:19
[21-Dec-2019 10:47:54 UTC] PHP   3. require_once() /chassis/wordpress/wp-blog-header.php:19
[21-Dec-2019 10:47:54 UTC] PHP   4. include() /chassis/wordpress/wp-includes/template-loader.php:98
[21-Dec-2019 10:47:54 UTC] PHP   5. get_template_part() /chassis/content/themes/koji/singular.php:11
[21-Dec-2019 10:47:54 UTC] PHP   6. locate_template() /chassis/wordpress/wp-includes/general-template.php:168
[21-Dec-2019 10:47:54 UTC] PHP   7. load_template() /chassis/wordpress/wp-includes/template.php:671
[21-Dec-2019 10:47:54 UTC] PHP   8. require() /chassis/wordpress/wp-includes/template.php:724
[21-Dec-2019 10:47:54 UTC] PHP   9. the_content() /chassis/content/themes/koji/content.php:23
[21-Dec-2019 10:47:54 UTC] PHP  10. apply_filters() /chassis/wordpress/wp-includes/post-template.php:253
[21-Dec-2019 10:47:54 UTC] PHP  11. WP_Hook->apply_filters() /chassis/wordpress/wp-includes/plugin.php:206
[21-Dec-2019 10:47:54 UTC] PHP  12. Tachyon::filter_the_content() /chassis/wordpress/wp-includes/class-wp-hook.php:288
[21-Dec-2019 10:47:54 UTC] PHP  13. compact() /chassis/vendor/humanmade/tachyon-plugin/inc/class-tachyon.php:363

The site in question is using smart media from Altis/media 2.x if that is likely to be having an effect.

peterwilsoncc avatar Dec 21 '19 11:12 peterwilsoncc

Night brain has been most helpful...

It looks like the cause here is $size remains undefined for full size images. This is the case for both images scaled and unscaled images in WordPress 5.3.

This was tested using the highly technical process of adding var_dump( $attachment_id, isset( $size ) ? $size : '! isset' ); above the tachyon_post_image_args hook.

I'll chuck a PR up in the next couple of weeks, if you set up a travis ci config (I didn't think to give myself write access to this repo) I'll throw in some unit tests.

peterwilsoncc avatar Dec 22 '19 00:12 peterwilsoncc

I think we need to handle full size more better in general, just hit another snag with gaussholder compat for full size images. Will do a PR to address these problems.

roborourke avatar Feb 19 '20 11:02 roborourke

Thanks Rob, sorry for the lack of promised PR. I figured out my night brain was almost correct in the message above but didn't provide complete information.

peterwilsoncc avatar Feb 19 '20 20:02 peterwilsoncc

Hmm, thinking about it now did you fix this in #50 ?

roborourke avatar Feb 19 '20 20:02 roborourke