Possible breaking changes for plugins in Unraid 6.12


SpencerJ

Recommended Posts

Unraid 6.12-rc1 just dropped!


Unraid version 6.12 introduces several changes which may have an impact on plugins and could lead to plugins not working correctly.

 

Plugin developers are encouraged to update their existing plugins to make them compatible and ensure they work correctly when users upgrade to Unraid 6.12. 


The following sections describe the areas of attention which may need to be modified going forward. These sections are broken out into separate comments below:

 

PHP 8.2

 

ID and CLASS attributes

 

Dashboard

  • Like 1
Link to comment

PHP 8.2 

 

Unraid 6.12 comes with an updated version of PHP. Previously, Unraid was using PHP 7.4, but this version is end of support, and is no longer receiving security updates. PHP 8.2 was released in December 2022 and is maintained for the next two years, plus an extension of another two years for security updates ensuring Unraid can benefit from any updates and fixes in PHP for the foreseeable future. 
Unfortunately, moving to PHP 8.2 introduces several breaking incompatibilities from PHP 7.4. All of the details can be found at https://www.php.net/ under the upgrading sections of each respective version. 


Here follows a summary of the most common fixes we needed to do for the GUI, and are likely also impacting plugins:


• It is no longer allowed to use an uninitialized variable as haystack.

This impacts many functions, and the common solution is to initialize the variable as an empty string as a zero value integer. 

All functions operating on strings, like strpos, strlen or substr are impacted and need to be addressed. Otherwise, they fail. 


• Several functions have been deprecated: PHP offers alternative solutions, described in detail on the website. 
For example, strftime() is such a function and needs to be replaced.

 
• To prevent PHP warnings, it is recommended to explicitly initialize variables before using them and use functions like: isset() or empty() to test a variable. 
Note: A new feature has been added which allows plugin authors to monitor PHP errors more easily. This new feature is under Tools -> PHP settings.

You can set a specific error reporting level and open the LOG view to observe any PHP errors in real time while browsing the GUI (and custom plugins). 

Link to comment

ID and CLASS attributes

In order to adhere to HTML standards, several elements previously identified by an ID attribute are changed and use a CLASS attribute instead. These elements can occur several times on an HTML page and should not use the ID attribute. 
The specific elements which are changed are the following: 
#title

- title is used for intermediate headers on the page 


#nav-item

- nav-item is used for GUI elements in the top header 
#nav-user

- nav-item is used for user defined elements in the top header

 

When a plugin is using or referring to any of these elements, it should be changed to a class attribute.

#title -> .title

#nav-item -> .nav-item

#nav-user -> .nav-user 

Link to comment

Dashboard

The dashboard has been redesigned, and it is now possible to move elements (tiles) up and down and between columns. This allows the user to organize the tiles in any way they desire.

Until now, no official API existed to add custom tiles to the dashboard, and plugins used their own “hacked” method. This method is no longer supported and must be changed to make custom tiles manageable similarly to standard tiles.

Together with Unraid 6.12 comes an example page file that describes how plugin authors can add their own elements to the dashboard and the updated structure of dashboard elements. 
This file is located under:

 

/usr/local/emhttp/webGui/DashboardCustomTileExample.page-


This file must be copied to the respective plugin folder and modified accordingly.

Link to comment
6 minutes ago, SpencerJ said:

Dashboard

The dashboard has been redesigned, and it is now possible to move elements (tiles) up and down and between columns. This allows the user to organize the tiles in any way they desire.

Until now, no official API existed to add custom tiles to the dashboard, and plugins used their own “hacked” method. This method is no longer supported and must be changed to make custom tiles manageable similarly to standard tiles.

Together with Unraid 6.12 comes an example page file that describes how plugin authors can add their own elements to the dashboard and the updated structure of dashboard elements. 
This file is located under:

 

/usr/local/emhttp/webGui/DashboardCustomTileExample.page-


This file must be copied to the respective plugin folder and modified accordingly.

You should include conditions on your existing dashboard page files similar to these.

 

Cond="version_compare(parse_ini_file('/etc/unraid-version')['version'],'6.11.9', '<')"

 

I have included links to new Dashboards as examples

https://github.com/SimonFair/gpustat-unraid/blob/master/src/gpustat/usr/local/emhttp/plugins/gpustat/gpustatusmovablemulti.page

https://github.com/SimonFair/USB_Manager/blob/main/source/USBDashMovable.page

https://github.com/SimonFair/NUT-unRAID/blob/master/source/nut/usr/local/emhttp/plugins/nut/nutFooter.page

https://github.com/SimonFair/IPMI-unRAID/blob/master/source/ipmi/usr/local/emhttp/plugins/ipmi/IPMIDashmovable.page

  • Thanks 2
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.