news icon indicating copy to clipboard operation
news copied to clipboard

PHP 8.1 depreciation warinings on null as paremeter

Open Synochy opened this issue 2 years ago • 8 comments

Explain the Problem

Logbook is filling with the following error: Error: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated at /var/www/nextcloud/apps/news/lib/Db/Item.php#386

System Information

  • News app version:18.0.1
  • Nextcloud version:24
  • PHP version: 8.1
  • Database and version: mysql 10.3.34
  • OS and version: Debian 11

Synochy avatar May 03 '22 14:05 Synochy

Ah I see the reason is that you have a feed without an author.

https://github.com/nextcloud/news/blob/fca05d50a6be4092b7a87fac1b417ee75d5c4461/lib/Db/Item.php#L384-L394 @SMillerDev should we just change the default to an empty string?

Grotax avatar May 03 '22 16:05 Grotax

Maybe just unknown author? But yeah, those should probably all be checked for default values.

SMillerDev avatar May 03 '22 16:05 SMillerDev

yea it's only strip that doesn't like null anymore as value. Do we need translation there, I guess for user friendly use we do..

I will look into it.

Grotax avatar May 03 '22 19:05 Grotax

i got that same or very similar error in 18.1.0 with php8.1 and NC24:

  Error    PHP                Error: html_entity_decode(): Passing null to parameter #1 
                              ($string) of type string is deprecated at 
                              /var/www/nextcloud/apps/news/lib/Db/Item.php#176 at 
                              lib/private/Log/ErrorHandler.php line 92

                              0. <<closure>>
                                 OC\Log\ErrorHandler::onError(

                                 )
                              1. .../news/lib/Db/Item.php line 176
                                 html_entity_decode(

                                 )
                              2. .../ItemServiceV2.php line 100 
                                 OCA\News\Db\Item->generateSearchIndex( 

                                 )
                              3. .../FeedServiceV2.php line 303 
                                 OCA\News\Service\ItemServiceV2->insertOrUpdate(

                                 )
                              4. .../FeedServiceV2.php line 342 
                                 OCA\News\Service\FeedServiceV2->fetch( 

                                 )
                              5. .../UpdaterService.php line 55 
                                 OCA\News\Service\FeedServiceV2->fetchAll(

                                 )
                              6. .../UpdaterJob.php line 71 
                                 OCA\News\Service\UpdaterService->update("*** sen ... *") 
                              7. .../Job.php line 54
                                 OCA\News\Cron\UpdaterJob->run( 

                                 )
                              8. .../TimedJob.php line 60 
                                 OC\BackgroundJob\Job->execute( 

                                 )
                              9. cron.php line 151
                                 OC\BackgroundJob\TimedJob->execute(

                                 )

D3V1LC0D3R avatar Jun 17 '22 12:06 D3V1LC0D3R

Yea probably caused by some field maybe "author" being null.

https://github.com/nextcloud/news/blob/1847635cf2450eb8239a56d8d952eef05f5b48dd/lib/Db/Item.php#L167-L185

Grotax avatar Jun 19 '22 11:06 Grotax

@SMillerDev maybe empty strings as defaults are actually easier

Grotax avatar Jun 19 '22 11:06 Grotax

We should just be checking the value rather than always stripping I think.

SMillerDev avatar Jun 19 '22 13:06 SMillerDev

I think #1861 will fix this

Grotax avatar Aug 18 '22 19:08 Grotax