Overview

In Omeka S, I encountered an issue where the error message “CSRF: Value is required and can’t be empty” was displayed when trying to save an item associated with many media, and saving would not complete.

This article explains how to address this error.

This is mentioned in articles such as the following. It appears to be a known error, and it is stated that php.ini needs to be modified.

https://forum.omeka.org/t/csrf-value-is-required-and-cant-be-empty/15421

https://github.com/omeka/omeka-s/issues/1472

Solution

Below is the response from ChatGPT.

To set max_input_vars in php.ini, follow these steps:

  1. Open the php.ini file. The location of php.ini varies depending on your environment, but it is commonly found in one of the following directories:

    • /etc/php/8.x/apache2/php.ini (Apache)
    • /etc/php/8.x/cli/php.ini (CLI)
    • /etc/php/8.x/fpm/php.ini (PHP-FPM)
  2. Set or change the value of max_input_vars. Look for the following line. If it does not exist, add it as a new line.

max_input_vars=1000

The value 1000 is the default, but you can change it to a larger number as needed. For example, to change it to 5000:

max_input_vars=5000
  1. Save the php.ini file.

  2. Restart the web server to apply the settings. For example, if you are using Apache, run the following command:

sudosystemctlrestartapache2

If you are using PHP-FPM, run:

sudosystemctlrestartphp8.x-fpm

This sets max_input_vars and the web server will reflect the setting.

Summary

In this case, setting max_input_vars = 5000 resolved the above error.

I hope this is helpful for those experiencing the same issue.