kylephillips / favorites

Simple and flexible favorite buttons for any WordPress post type.
https://favoriteposts.com
223 stars 86 forks source link

Multiple issues detected when running on PHP 8 #184

Open vandevusse opened 1 year ago

vandevusse commented 1 year ago

Succinct list of issues found so far as follows:

  1. Helpers::keyExists $haystack can be passed as empty, causes in_array function to throw exception

  2. UserRepository::isFavorite $favorites can be empty, causes in_array function to throw exception

  3. SyncSingleFavorite::addFavorite $favorites[$key]['posts'][] = $this->post_id; causes the following error: Fatal error: [] operator not supported for strings I believe the issue here is that the $favorites[$key]['posts'] array is not initialized

Issue also occurs lower down at $favorites[$key]['groups'][$group_key]['posts']

MacGyer commented 4 months ago

Another one, introduced with 2.3.4:

PHP Deprecated: Optional parameter $site_id declared before required parameter $all_favorites is implicitly treated as a required parameter