Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294952

File entity - Dblog/Watchdog entries if uid is NULL

$
0
0

Problem/Motivation

File entities have a field called "uid" storing the id of the owning user. The field is not marked as required and is not part of the entity keys. As a result, the Drupal API as well as the underlying database allow NULL values in the uid field.

The code in \Drupal\file\FileAccessControlHandler::checkAccess assumes that there is always an integer. If it is null, PHP creates an E_NOTICE on the $file_uid[0]['target_id'] expression, which by default ends up in the watchdog DB table.

Steps to reproduce

Call the file APIs functions such as File::create([...]) or file_save_data(...) from a cron or drush context.

Proposed resolution

Call getOwnerId() instead.


Viewing all articles
Browse latest Browse all 294952

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>