Skip to content

OriginalDateTimeMetadataProvider unexpected null value #2225

@jakkarth

Description

@jakkarth

Describe the bug
When generating metadata for a file, an unhandled exception is thrown. OriginalDateTimeMetadataProvider.php on line 90 is assuming that because the array key exists, its corresponding value cannot be null, and passes it as arg 2 to dateToTimestamp.

To Reproduce
Steps to reproduce the behavior:

  1. Have a file with some unexpected? metadata in it?
  2. Inside the docker container, use occ to generate metadata php occ files:scan --generate-metadata --all -v --path '/myuser/files/Photos/AFolder/PXL_20231225_235744352.jpg'

Expected behavior
Metadata is properly generated without any errors. occ proceeds on to the next file.

Actual behavior
Unhandled exception is thrown, metadata isn't generated, stack trace is printed to console, occ exits non-zero.

Stack Trace

An unhandled exception has been thrown:
TypeError: OCA\Photos\Listener\OriginalDateTimeMetadataProvider::dateToTimestamp(): Argument #2 ($date) must be of type string, null given, called in /var/www/html/apps/photos/lib/Listener/OriginalDateTimeMetadataProvider.php on line 90 and defined in /var/www/html/apps/photos/lib/Listener/OriginalDateTimeMetadataProvider.php:49
Stack trace:
#0 /var/www/html/apps/photos/lib/Listener/OriginalDateTimeMetadataProvider.php(90): OCA\Photos\Listener\OriginalDateTimeMetadataProvider->dateToTimestamp('Y:m:d G:i:s', NULL, Object(OC\Files\Node\File))
#1 /var/www/html/lib/private/EventDispatcher/ServiceEventListener.php(86): OCA\Photos\Listener\OriginalDateTimeMetadataProvider->handle(Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#2 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(230): OC\EventDispatcher\ServiceEventListener->__invoke(Object(OCP\FilesMetadata\Event\MetadataLiveEvent), 'OCP\\FilesMetada...', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#3 /var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php(59): Symfony\Component\EventDispatcher\EventDispatcher->callListeners(Array, 'OCP\\FilesMetada...', Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#4 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(94): Symfony\Component\EventDispatcher\EventDispatcher->dispatch(Object(OCP\FilesMetadata\Event\MetadataLiveEvent), 'OCP\\FilesMetada...')
#5 /var/www/html/lib/private/EventDispatcher/EventDispatcher.php(106): OC\EventDispatcher\EventDispatcher->dispatch('OCP\\FilesMetada...', Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#6 /var/www/html/lib/private/FilesMetadata/FilesMetadataManager.php(115): OC\EventDispatcher\EventDispatcher->dispatchTyped(Object(OCP\FilesMetadata\Event\MetadataLiveEvent))
#7 /var/www/html/apps/files/lib/Command/Scan.php(142): OC\FilesMetadata\FilesMetadataManager->refreshMetadata(Object(OC\Files\Node\File), 3, '')
#8 [internal function]: OCA\Files\Command\Scan->OCA\Files\Command\{closure}('/myuser/files/Photo...')
#9 /var/www/html/lib/private/Hooks/EmitterTrait.php(105): call_user_func_array(Object(Closure), Array)
#10 /var/www/html/lib/private/Hooks/PublicEmitter.php(40): OC\Hooks\BasicEmitter->emit('\\OC\\Files\\Utils...', 'scanFile', Array)
#11 /var/www/html/lib/private/Files/Utils/Scanner.php(133): OC\Hooks\PublicEmitter->emit('\\OC\\Files\\Utils...', 'scanFile', Array)
#12 [internal function]: OC\Files\Utils\Scanner->OC\Files\Utils\{closure}('files/Photos/AF...', 'home::myuser')
#13 /var/www/html/lib/private/Hooks/EmitterTrait.php(105): call_user_func_array(Object(Closure), Array)
#14 /var/www/html/lib/private/Files/Cache/Scanner.php(173): OC\Hooks\BasicEmitter->emit('\\OC\\Files\\Cache...', 'scanFile', Array)
#15 /var/www/html/lib/private/Files/Cache/Scanner.php(345): OC\Files\Cache\Scanner->scanFile('files/Photos/AF...', 3, -1, NULL, true)
#16 /var/www/html/lib/private/Files/Utils/Scanner.php(273): OC\Files\Cache\Scanner->scan('files/Photos/AF...', true, 3)
#17 /var/www/html/apps/files/lib/Command/Scan.php(180): OC\Files\Utils\Scanner->scan('/myuser/files/Photo...', true, NULL)
#18 /var/www/html/apps/files/lib/Command/Scan.php(241): OCA\Files\Command\Scan->scanFiles('myser', '/myuser/files/Photo...', '', Object(Symfony\Component\Console\Output\ConsoleOutput), false, true, false)
#19 /var/www/html/3rdparty/symfony/console/Command/Command.php(298): OCA\Files\Command\Scan->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/html/core/Command/Base.php(177): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/html/3rdparty/symfony/console/Application.php(1040): OC\Core\Command\Base->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/html/3rdparty/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Files\Command\Scan), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /var/www/html/3rdparty/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /var/www/html/lib/private/Console/Application.php(206): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /var/www/html/console.php(100): OC\Console\Application->run()
#26 /var/www/html/occ(11): require_once('/var/www/html/c...')
#27 {main}

Additional context
Problem is 100% reproducible Unfortunately due to privacy I cannot share the photo that is causing the problem. Other images are processed just fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending approval or rejection. This issue is pending approval.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions