backdrop-contrib / flag

Flag module for Backdrop CMS
0 stars 11 forks source link

Notice: unserialize(): Error at offset 33 of 444 bytes in flag_flag::factory_by_row() #44

Closed alanmels closed 8 months ago

alanmels commented 11 months ago

On a fresh Backdrop setup running on PHP 8.1 it gives:

[Notice: unserialize(): Error at offset 33 of 444 bytes in flag_flag::factory_by_row() (line 131 of /var/www/html/docroot/modules/contrib/flag/includes/flag/flag_flag.inc).](https://main.ddev.site/admin/reports/event/1)
alanmels commented 11 months ago

Even-though https://www.drupal.org/project/flag/issues/2936075 concluded the problem id corrupt data in DB - which is true - it is easily reproducible by taking the following steps:

  1. Go to admin/structure/flags and create a new flag.
  2. In "Flag link text" and "Unflag link text" put any UNICODE symbol.
  3. Export the db (for example, with bee db-export) and import it to your development branch (another Backdrop setup).
  4. Login to the website without clearing cache, go to admin/structure/flags and the admin/reports/dblog will show the reported error.
  5. Clear cache and you will see the Attempt to assign property "id" on bool error and the website is not accessible anymore.
alanmels commented 11 months ago

If module maintainers will want to troubleshoot this, then here is the exported flag that caused the error ob database export and import. Interesting is that after you export the DB and then import it to another Backdrop website, the values for Flag link text and Unflag link text on admin/structure/flags/manage/thumbsup are never there (and that causes the error), so you have to manually enter the 👍 and 'unflag' on each time you upload a DB, because otherwise you end up with a broken site.

$flags = array();
// Exported flag: "Thumbsup".
$flags['thumbsup'] = array (
  'entity_type' => 'comment',
  'title' => 'Thumbsup',
  'global' => '0',
  'types' => 
  array (
    1 => 'comment_node_post',
    2 => 'comment_node_task',
  ),
  'flag_short' => '👍',
  'flag_long' => '',
  'flag_message' => '',
  'unflag_short' => 'unflag',
  'unflag_long' => '',
  'unflag_message' => '',
  'unflag_denied_text' => '',
  'link_type' => 'toggle',
  'weight' => 0,
  'show_in_links' => 
  array (
    'full' => 0,
    'token' => 0,
  ),
  'show_as_field' => 0,
  'show_on_form' => 0,
  'access_author' => '',
  'show_contextual_link' => 0,
  'api_version' => 3,
);
return $flags;
alanmels commented 8 months ago

This has magically been fixed by the last version. So I guest one of the last commits played the role.