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

PHP Fatal error: Uncaught TypeError: array_merge(): Argument #2 must be of type array, string given in syndication-links/includes/class-syn-meta.php:97 #176

Closed
janboddez opened this issue Feb 8, 2023 · 10 comments

Comments

@janboddez
Copy link

Might be an edge case, but I ran into this playing around with the settings.

In short, I disabled all post types (which maybe you shouldn't do, but it is possible ...). Looks like the option is then deleted (?), causing get_option() to return an empty string (the default).

Could likely be fixed by adding a default option (get_option( '<something-something>', array() ), or checking for an empty value (if ( empty( $post_types ) ) and so on ...).

Speaking of: what is the preferred way to not append any links to post_content but keep the WP-Admin meta box? Remove the the_content filter? (I'm looking into doing this in a block outside the post content / e-content.) There's a "no display" setting, but I was under the impression that this would still add hidden links.

@dshanske
Copy link
Owner

dshanske commented Feb 9, 2023

@janboddez It is in the readme.

syndication_links_display( true ) - Adds Syndication Links to content display.

Just add a false return to this filter.

@janboddez
Copy link
Author

janboddez commented Feb 10, 2023

Just FYI: the actual issue is definitely still present.

[10-Feb-2023 12:39:10 UTC] PHP Fatal error:  Uncaught TypeError: array_merge(): Argument #2 must be of type array, string given in <...>/syndication-links/includes/class-syn-meta.php:97
Stack trace:
#0 <...>/syndication-links/includes/class-syn-meta.php(97): array_merge()
#1 <...>/syndication-links/includes/class-syn-meta.php(102): Syn_Meta::screens()
... 

Reappeared the moment I reinstalled and activated the (latest version of the) plugin. (Presumably because the faulty setting is never purged, which is okay, as long as the code itself is able to handle it.)

@dshanske
Copy link
Owner

I'll do the full array check then

@dshanske dshanske reopened this Feb 10, 2023
@janboddez
Copy link
Author

Can give it another look later too. Might be sufficient to cast to an array, which I think would give you either an empty array or one with an empty string in it, at least until one or more post types are selected and saved. That would likely prevent the fatal error.

@dshanske
Copy link
Owner

I have to upgrade my dev testing from 7.4 to 8.

@dshanske
Copy link
Owner

@janboddez Check again?

@janboddez
Copy link
Author

I now get, or rather, got the error on the settings page only instead of it taking down the entire site. :-)

image

Mind you, I did not purge the settings from the database before reinstalling. Once I selected that first unlabeled checkbox and forced the form to submit, the error disappeared.

@janboddez
Copy link
Author

I'll have a look at the actual error as soon as I get the chance. (No longer actively using the plugin so it's not super urgent [for me] ...)

@dshanske
Copy link
Owner

Tried the other way of dealing with this.

@janboddez
Copy link
Author

This works/no longer throws an error.

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

2 participants