Gallery not working in MODx 3

I am getting PHP Fatal Errors with Gallery and SimpleSearch.
Clean MODx 3.0.2-pl install, Gallery 2.0.1-pl.
PHP 7.2.34 (the same with PHP 7.3).

The errors are related to incompatible class functions declarations and return types in GalleryAlbumsMediaSource when creating or editing Media Source:

PHP Fatal error: Declaration of Gallery\\Model\\GalleryAlbumsMediaSource::getObjectContents(string $objectPath): bool must be compatible with MODX\\Revolution\\Sources\\modMediaSource::getObjectContents($path) in /home/core/components/gallery/src/Model/GalleryAlbumsMediaSource.php on line 504

I can see many such functions incompatible between GalleryAlbumsMediaSource and modMediaSource classes. Higher PHP versions are even more strict about type declarations.
Some people mention that it’s working fine for them. Am I missing something here?

Yes, it seems that multiple function declarations have to be adapted to make it work.

Most people probably just don’t use the Gallery-MediaSource.
Do you really need it? The only thing it is good for, is to move images from one gallery to another.

Thanks for your reply. I can confirm that Gallery is working by itself, but there are some nasty glitches:

  • Gallery is creating files under defined Media Source. System setting gallery.files_path is relative to that Media Source. So you can’t move gallery files outside default Media Source. Users don’t have to see it’s file structure mixed with other user uploaded files.
  • Built-in phpthumb is assuming gallery.files_path value to be assets/something. If you change this setting to something, files are uploaded to something, but phpthumb is trying to find assets/something, thus breaking thumbs
  • Despite PHP fatal error thrown when editing or creating Media Source, that media source is still created/edited. But you can’t change it’s Source Type, it remains to default MODX\Revolution\Sources\modFileMediaSource. So you can’t create e.g. S3 media sources. Workaround would be to uninstall Gallery, create the source and then reinstall

FYI Gallery had a serious security vulnerability, and AFAIK, it hasn’t been updated for a number of years and is no longer supported. I don’t know if the security issue affects MODX 3, but you might want to look at some alternatives, like MoreGallery from Modmore.

Well, the last update was 2 months ago.
I’ve never heard of this “serious security vulnerability”. Are you sure this is still an issue?

Yes, there was such vulnerability several years ago, but it was already patched.
The reason why we are trying to make it work is upgrade of existing 2.x MODx installations to 3.x. We have several very large installations, so testing safest upgrade path instead of installing different extras.

Btw MoreGallery is nice and seems to be the only real replacement for Gallery for now. But migration of existing sites would be difficult.


Googling Modx Github Gallery sent me to Splittingred’s site for Gallery. I missed the fine print that would have forwarded me to the fork.