RRZE-Webteam / fau-cris

Wordpress-Plugin: Shortcodes für die Einbindung von Daten aus dem FAU Forschungsportal CRIS
5 stars 4 forks source link

Fatal Fehler je nach Id #287

Closed xwolfde closed 1 year ago

xwolfde commented 1 year ago

Geht fehlerfrei: [cris show="projects" project="266469022"] [cris show="projects" project="126308584" hide=""] [cris show="projects" project="126269883"] [cris show="projects" project="126125219" hide="abstract"] [cris show="projects" project="126311964"]

Fatal: [cris show="projects" project="126466768"] [cris show="projects" project="266595362"]

xwolfde commented 1 year ago

Nebenbeobachtung: Die 2 Projekte mit Fehlern haben in ihren Projekttiteln Sonderzeichen. vgl: https://cris.fau.de/converis/portal/Project/126466768?auxfun=&lang=de_DE

lukasniebler commented 1 year ago

[cris show=fields field=267048115 hide=persons status=current] wirft fatal

--
[2023-08-31 13:55:55.907473] [error] [proxy_fcgi] [141.67.169.126:50675] AH01071: Got error 'PHP message: PHP Warning: Attempt to read property "attributes" on bool in /proj/cms/rrze/vhosts/cms.rrze.uni-erlangen.de/websource/wp-content/plugins/fau-cris/class_Publikationen.php on line 489PHP message: PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, null given in /proj/cms/rrze/vhosts/cms.rrze.uni-erlangen.de/websource/wp-content/plugins/fau-cris/class_Publikationen.php:489\nStack trace:\n#0 /proj/cms/rrze/vhosts/cms.rrze.uni-erlangen.de/websource/wp-content/plugins/fau-cris/class_Forschungsbereiche.php(488): Publikationen->fieldPub()\n#1 /proj/cms/rrze/vhosts/cms.rrze.uni-erlangen.de/websource/wp-content/plugins/fau-cris/class_Forschungsbereiche.php(298): Forschungsbereiche->get_field_publications()\n#2 /proj/cms/rrze/vhosts/cms.rrze.uni-erlangen.de/websource/wp-content/plugins/fau-cris/class_Forschungsbereiche.php(99): Forschungsbereiche->make_single()\n#3 /proj/cms/rrze/vhosts/cms.rrze.uni-erlangen.de/websource/wp-content/plugins/fau-cris/fau-cris.php(779): Forschungsbereiche->singleField()\n#4 /proj/cms/rrze/vhosts/cms.rrze.uni-erlangen.de/websource/wp-includes/shortcodes.php(395): FAU_CRIS::cris_shortcode()\n#5 [internal function]:...'
rvdforst commented 1 year ago

Das Problem entsteht, weil der Code Bedingungen wie:

if (array_key_exists('relation right seq', reset($pubArray)->attributes)) {
  $sortby = 'relation right seq';
  $orderby = $sortby;
}

enthält, bei denen Typ und Inhalt der Argumente nicht überprüft werden. Der richtige Code hier wäre (PHP 8.0):

$firstItem = reset($pubArray);
if ($firstItem && isset($firstItem->attributes['relation right seq'])) {
  $sortby = 'relation right seq';
  $orderby = $sortby;
}

bzw. PHP 8.1:

if (reset($pubArray)?->attributes['relation right seq']) {
  $sortby = 'relation right seq';
  $orderby = $sortby;
}
rvdforst commented 1 year ago

Ich denke, dass mit Version 3.19.2 die meisten Probleme im Zusammenhang mit diesem Issue gelöst wurden, es gibt jedoch immer noch Code, der überprüft werden muss.