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

Plugin doesn't work if opcache.save_comments is disabled. #206

Open
spacedmonkey opened this issue Sep 9, 2020 · 1 comment
Open

Plugin doesn't work if opcache.save_comments is disabled. #206

spacedmonkey opened this issue Sep 9, 2020 · 1 comment
Assignees

Comments

@spacedmonkey
Copy link

spacedmonkey commented Sep 9, 2020

Bug Description

Opache is caching in PHP, it takes your PHP code and compile it, so your site runs faster. For some large hosting companies they enable a flag called save_comments.

Quote from docs.

If disabled, all documentation comments will be discarded from the opcode cache to reduce the size of the optimised code. Disabling this configuration directive may break applications and frameworks that rely on comment parsing for annotations, including Doctrine, Zend Framework 2 and PHPUnit.

The wp-foo-bar use annotations to hook in filters and actions.

As comments are required for these filters / actions to hooked, when opache removes them, the plugin does not function.

Expected Behaviour

Plugin should work if opcache.save_comments is disabled, as many hosting companies may disable save_comments

Steps to reproduce

Set opache.save_comments = false.

Acceptance criteria

Implementation brief

Simply use php hooks

add_filter( 'the_content', [ $this, 'hotlink_images_in_content'] , 99, 1 );

QA testing instructions

Demo

Changelog entry

  • Refactored code to work when Opache.save_comment is set to false.

Original bug: xwp/unsplash-wp#195
Original Fix: xwp/unsplash-wp#197
Original bug reports - Settings won’t load on install

@rheinardkorf
Copy link

Only seeing this issue now. I am 100% in favour of fixing this, but it has significant consequences for any plugins already built that uses the current mechanism.

wp-foo-bar uses reflection to automatically create the WP hooks required by parsing comment blocks. Though clever, it is not technically "The WordPress Way" and can often be confusing for developers who start building with wp-foo-bar and frustrating if you're working on a project that does not do this.

Having Opcache strip out comments is enough validation for me that this is not the ideal way to do WP hooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants