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

Fatal Error: incompatible extended methods #40

Closed
mikeselander opened this issue Mar 30, 2018 · 3 comments
Closed

Fatal Error: incompatible extended methods #40

mikeselander opened this issue Mar 30, 2018 · 3 comments
Labels

Comments

@mikeselander
Copy link
Contributor

mikeselander commented Mar 30, 2018

On Chassis with PHP7.2, I get the following fatal error when attempting to load WP:

It looks like the signatures of each of the extended types are different and we can no longer get away with this.

Fatal error: Declaration of HMCI\Inserter\WP\Attachment::insert($path, $post_data = Array, $canonical_id = false, $post_meta = Array, $file_type_override = NULL, $force_update_existing = true) must be compatible with HMCI\Inserter\WP\Post::insert($post_data = Array, $canonical_id = false, $post_meta = Array) in /vagrant/content/client-mu-plugins/hm-content-import/inc/classes/inserter/wp/attachment.php on line 0

Time Memory Function Location
1 0.0004 396696 {main}( ) .../index.php:0
2 0.0018 396984 require( '/vagrant/wp/wp-blog-header.php' ) .../index.php:7
3 0.0025 397336 require_once( '/vagrant/wp/wp-load.php' ) .../wp-blog-header.php:13
4 0.0040 398256 require_once( '/vagrant/wp-config.php' ) .../wp-load.php:42
5 0.0089 402200 require_once( '/vagrant/wp/wp-settings.php' ) .../wp-config.php:145
6 0.1682 3297088 include_once( '/vagrant/content/mu-plugins/z-client-mu-plugins.php' ) .../wp-settings.php:260
7 0.1727 3299176 include_once( '/vagrant/content/client-mu-plugins/loader.php' ) .../z-client-mu-plugins.php:117
8 0.1779 3300576 require_once( '/vagrant/content/client-mu-plugins/hm-content-import/hm-content-import.php' ) .../loader.php:26

Additionally:
Fatal error: Declaration of HMCI\Inserter\WP\Guest_Author::insert($user_data = Array, $canonical_id = false, $author_meta = Array) must be compatible with HMCI\Inserter\WP\Post::insert($post_data = Array, $canonical_id = false, $post_meta = Array, $options = Array) in /vagrant/content/client-mu-plugins/hm-content-import/inc/classes/inserter/wp/guest-author.php on line 0
Fatal error: Declaration of HMCI\Inserter\WP\Attachment::exists($canonical_id) must be compatible with HMCI\Inserter\WP\Post::exists($canonical_id, $post_type = 'post') in /vagrant/content/client-mu-plugins/hm-content-import/inc/classes/inserter/wp/attachment.php on line 0

@tcrsavage
Copy link
Contributor

tcrsavage commented Apr 2, 2018

Hmm, that's a bit annoying. Bit of a clash with established design patterns and the use case we have here.

If we wanted to hack this in the "WordPress" way, we'd go for a generic $args array as an optional:

function insert( $object_data, $canonical_id, $meta, $args = [] );

Where we can support args which don't fit into the standard structure. Bit messy in my opinion, doesn't lead to good hinting, but may well be the best option.

Another more "correct" option might be something like:

$inserter = new Attachment( $author_data, $canonical_id, $author_meta );
$inserter->set_file_type_override( 'jpg' );
$inserter->insert();

@mikeselander if this is blocking you, happy to take a PR to transfer additional args for inserters into generic $args array, should be able to normalise everything quite easily with that approach.

@tcrsavage
Copy link
Contributor

cc @shadyvb wonder if you have any thoughts here too

@tcrsavage
Copy link
Contributor

Ahh, mb, you've already produced a PR doing just that: https://github.com/humanmade/hm-content-import/pull/41/files

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

No branches or pull requests

2 participants