LibreBooking / app

Repository for the last open source version of Booked Scheduler. The "develop" branch contains the most current working code of the project and should be considered beta. The "master" branch is the most current stable release of BookedScheduler. Please read doc/README.md for further details.
GNU General Public License v3.0
371 stars 220 forks source link

Smarty warnings on new installation - Smarty 4.5.3 #363

Open daj1u06 opened 1 month ago

daj1u06 commented 1 month ago

Fresh install of Librebooking stable 2.8.6.1 with xampp 3.3.0 on win10. I received lots of smarty deprecated warnings on both installation using web/install and when visiting any page on the installed site; all of type: Deprecated: Using unregistered static method "ReservationStatus::Pending" in a template is deprecated and will be removed in a future release. Use Smarty::registerClass to explicitly register a class for access. in C:\xampp\htdocs\biubooked\vendor\smarty\smarty\libs\sysplugins\smarty_internal_templateparser.php on line 2428

I didn't get these on a previous install of the same LibreBooking release and xampp on this PC for which composer installed smarty v4.3.4. This time when I re-ran Composer it updated to smarty v4.5.3.

These warnings have a somewhat weird behaviour (to me at least).

• They only appear the first time that I visit a page • They don’t appear if I revisit a page after closing down and restarting browser. • They don’t appear if I revisit a page after closing down xampp and restarting. • They don’t appear if I revisit a page after clearing browwsercache / history. • They don’t reappear if I use a different browser, unless I've not visited that page before. • If I create a new standard user and log in as them, I saw no warnings except the first time I visited sections under help! (maybe because I've already visited all other pages under another (admin) login). So it seems that these warnings are a one-off event that must be logged somewhere as having been shown.

I know that they are only warnings and apparently one-off but it would be nice to resolve this as I'm going to be setting up multiple instances of librebooking in the same xampp / PC for different laboratories.

The internet suggests that I could do this in a few ways:

(1) just turn off warning in php.ini (maybe not a good idea)

(2) just turn off warnings in Smarty using something like: $smarty->error_reporting = error_reporting() & ~E_USER_DEPRECATED; But I don't know / can't find out where I would put this code. (3) do what the warning suggests and properly register the static methods using Smarty::registerClass to explicitly register each for access. Again I can't find out where I would put these statements and where / how I would get a full list of the static methods to specify, given their transient appearance.

Thanks in advance for any ideas.

JohnVillalovos commented 1 month ago

I noticed the same thing a few days ago. For the moment I have done the ignore the warnings. Not sure if it can be done in php.ini or not.

I added after this line: https://github.com/LibreBooking/app/blob/22c526a2a330091a6f18ade54697f64e0143ab05/Pages/Page.php#L42

$this->smarty->error_reporting = error_reporting() & ~E_USER_DEPRECATED

Based on reading: https://github.com/smarty-php/smarty/issues/958

Long term fix is to register the classes.

daj1u06 commented 1 month ago

Thanks John, massively appreciated. Have done that now.