webtrees
webtrees copied to clipboard
GedcomRecordPage check for standard records is problematic
The 'in_array' check doesn't account for custom records replacing the standard records (not even subclasses work):
If I use e.g. a custom individual record via IndividualFactoryInterface, this check doesn't detect that.
Result is that links e.g. from the error report aren't redirected to the normal individual page, and end up on a generic edit-record page.
Perhaps just replace the entire check (including the xref part), i.e. lines 94-96 with this:
$genericRecord = Registry::gedcomRecordFactory()->new($xref, '', null, $tree);
if ($record->url() !== $genericRecord->url()) {
return redirect($record->url());
}
(or some equivalent check to determine whether it's a generic record, or a record created by a specific factory)
Would it work for you if we had this:
if ($record instanceof XXX || $record instanceof YYY || ...) {
redirect...
}
That would work as well, as custom factories always return subclasses of the respective type (I assumed above they could return any subclass of GedcomRecord, but that's not the case).
~~How about~~
~~if ($record instanceof GedcomRecord && get_class($record) !== GedcomRecord::class) { redirect }
~~
~~This should handle all sub-classes.~~
No, this wouldn't work. Need more coffee before I start coding :-)
There could be custom record types that we do not know about.
I think your original idea using URLs might be better. Something like:
if ($record->url() !== $request->url()) {}