setInfoMessage not working as expected

Created on 9 March 2019, over 6 years ago
Updated 24 July 2025, 19 days ago

In file drupal8\modules\h5p\vendor\h5p\h5p-core\h5p.classes.php line 950
$this->h5pF->setInfoMessage($this->h5pF->t("Note that the libraries may exist in the file you uploaded, but you're not allowed to upload new libraries. Contact the site administrator about this."));
This "InfoMessage" never gets displayed, unless there is already a Drupal info message at the top of the screen. In the attached screenshot illustration I put the site in maintenance just to get that message zone occupied, so that the H5P info message could get displayed!
Even then, it does not make sense to display such a message at the top of the screen, too far away from the location of the current problem.
Simple fix: I suggest sending that message along with the error message "Validating H5P PACKAGE failed" + Missing required library.
Please note that starting with Drupal 8.5, drupal_get_message() and drupal_set_message() are deprecated and replaced by Messenger service: https://www.drupal.org/node/2774931 β†’

πŸ› Bug report
Status

Active

Component

User interface

Created by

πŸ‡«πŸ‡·France papijo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States illeace

    I have confirmed this still happens in 2.0.0-alpha5. Here are steps to reproduce this:

    • Create a user whose roles do *not* have the "Update H5P libraries" permissions.
    • Identify a library that does not yet exist on your install
    • Create / download an H5P that uses that library elsewhere
    • In the H5P Editor, attempt to upload that H5P
    • It will fail with the error "Validating h5p package failed."
    • If you navigate to another page on the site, then you will see the "Note that the libraries may exist in the file you uploaded..." message.
  • πŸ‡ΊπŸ‡ΈUnited States illeace

    Looking closer, this seems like an issue in the H5P core library. In vendor/h5p/h5p-editor/h5peditor-ajax.class.php line 373, in the isValidPackage() function:

            $this->core->h5pF->getMessages('error')
    

    ... the core library is onlyl getting the error messages and ignoring the info message, the one mentioned in the original post. If either that message was set as an error or if the isValidPackage() function retrieved both info *and* error messages, then we would see that message in the H5P hub immediately. Something like this:

      private function isValidPackage($skipContent = FALSE) {
        $validator = new H5PValidator($this->core->h5pF, $this->core);
        if (!$validator->isValidPackage($skipContent, FALSE)) {
          $this->storage->removeTemporarilySavedFiles($this->core->h5pF->getUploadedH5pPath());
    
          $messages =  array_merge($this->core->h5pF->getMessages('info'), $this->core->h5pF->getMessages('error'));
          H5PCore::ajaxError(
            $this->core->h5pF->t('Validating h5p package failed.'),
            'VALIDATION_FAILED',
            NULL,
            $messages
          );
          return FALSE;
        }
    
        return TRUE;
      }
    

    In any case, I think this issue belongs in the H5P core library issue queue and not in the Drupal module.

Production build 0.71.5 2024