Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted January 25Jan 25 The issue is in the file /system/Content/Api/ItemController.php inside the function _createOrUpdate() on line 369: /* Update first comment if required, and it's not a new item */ $field = isset( $item::$databaseColumnMap['first_comment_id'] ) ? $item::$databaseColumnMap['first_comment_id'] : NULL; $commentClass = $item::$commentClass; $contentField = $commentClass::$databaseColumnMap['content']; if ( $item::$firstCommentRequired AND isset( $item->$field ) AND isset( \IPS\Request::i()->$contentField ) AND $type == 'edit' ) { [...]When no $commentClass is set, the next line tries to load a non-existent class/array field and throws an error: $contentField = $commentClass::$databaseColumnMap['content'];Error thrown with message "Class name must be a valid object or a string"The whole code block must be wrapped inside an IF check: $commentClass = $item::$commentClass; if ( $commentClass !== NULL ) { $contentField = $commentClass::$databaseColumnMap['content']; if ( $item::$firstCommentRequired AND isset( $item->$field ) AND isset( \IPS\Request::i()->$contentField ) AND $type == 'edit' ) { $content = \IPS\Request::i()->$contentField; if ( $this->member ) { $content = \IPS\Text\Parser::parseStatic( $content, TRUE, NULL, $this->member, $item::$application . '_' . mb_ucfirst( $item::$module ) ); } try { $comment = $commentClass::load( $item->$field ); } catch ( \OutOfRangeException $e ) { throw new \IPS\Api\Exception( 'NO_FIRST_POST', '1S377/1', 400 ); } $comment->$contentField = $content; $comment->save(); /* Update Search Index of the first item */ if ( $item instanceof \IPS\Content\Searchable ) { \IPS\Content\Search\Index::i()->index( $comment ); } } }The same issue affects also v5.0.0.