*

rooman

  • *****
  • 253 posts
Hello,

I am using Osclass with a blog plugin, and after upgrading to PHP 8 I started getting many warnings in the error log.

The warnings look like this:

Code: [Select]
PHP Warning: Undefined array key "fk_i_user_id"
PHP Warning: Undefined array key "pk_i_id"
PHP Warning: Undefined array key "i_category"
PHP Warning: Undefined array key "dt_pub_date"
PHP Warning: Undefined array key "i_view"
PHP Warning: Undefined array key "s_image"

The errors come from these files:

Quote
oc-content/plugins/blog/form/article.php
oc-content/plugins/blog/form/sidebar.php
oc-content/plugins/blog/functions.php

 My questions:
Why is $article missing these keys in some pages?
Is this a compatibility issue with PHP 8 or a plugin bug?
What is the correct way to fix this in Osclass plugins?
Should I use isset() / ?? everywhere, or is there a better global fix?
 Additional info:

The blog works, but these warnings appear on almost every article page.


Any help would be appreciated.

*

MB Themes

Re: PHP Warning: Undefined array key in blog plugin (PHP 8 issue)
« Reply #1 on: April 21, 2026, 02:46:09 PM »
Do you use latest plugin version?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

rooman

  • *****
  • 253 posts
Re: PHP Warning: Undefined array key in blog plugin (PHP 8 issue)
« Reply #2 on: April 21, 2026, 04:52:58 PM »
Do you use latest plugin version?
"Actually, I am not using the latest version because I have made several custom modifications to the plugin's core files, and updating would overwrite those changes.

I am looking to fix these warnings manually. Since I am on PHP 8, I know I should use isset() or the null coalescing operator (??).

Could you confirm if applying the following change to the affected lines is the recommended approach for Osclass plugins?

Example:
Change $article['fk_i_user_id'] to ($article['fk_i_user_id'] ?? '')

Also, if there is a specific logic in the blog plugin that causes these keys to be empty on certain pages, I would appreciate any insight."

*

MB Themes

Re: PHP Warning: Undefined array key in blog plugin (PHP 8 issue)
« Reply #3 on: April 22, 2026, 08:18:16 AM »
In such case not much to do, you need to go file by file and fix these notices.
This is ideal way:
Code: [Select]
$article['fk_i_user_id'] ?? ''
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

rooman

  • *****
  • 253 posts
Re: PHP Warning: Undefined array key in blog plugin (PHP 8 issue)
« Reply #4 on: April 22, 2026, 12:00:02 PM »
In such case not much to do, you need to go file by file and fix these notices.
This is ideal way:
Code: [Select]
$article['fk_i_user_id'] ?? ''
Hello,

Thank you very much for your clear and helpful explanation.

I really appreciate your guidance regarding the PHP 8 compatibility issue in the Osclass blog plugin. Your confirmation that the correct approach is to update each file and use the null coalescing operator (??) or isset() has been very helpful.

I will proceed with fixing the plugin files accordingly.

Thanks again for your support and time.

Best regards,