sanskrit-lexicon / COLOGNE

Development of http://www.sanskrit-lexicon.uni-koeln.de/
18 stars 3 forks source link

revisions per PHP 8.2 #401

Open funderburkjim opened 1 year ago

funderburkjim commented 1 year ago

A user (Peter Scharf) wanted to update the dictionary displays on a Mac computer. Mac computers have stopped pre-installing PHP. He finally got php installed, using homebrew and changing a few settings (I'm not sure which were changed).

Then he used the (mwweb1.zip at https://sanskrit-lexicon.uni-koeln.de/scans/MWScan/2020/web/webtc/download.html) and put this 'web' directory in the appropriate spot (/Library/Webserver/Documents/cologne/mw/web).

Now the displays partially worked, but exhibited a bunch of new PHP warnings, such as

Deprecated: Creation of dynamic property Dal::$status is deprecated in 
C:\xampp\htdocs\cologne\mw_phpchg_work\web\webtc\dal.php on line 71

It turns out that this 'dynamic property' deprecation was introduced in php 8.2; since I had been running php 8.1.1 locally, and also not yet php 8.2 at Cologne, this warning had not occurred previously.

Further comments will describe the (easy) fix, and what files were changed.

funderburkjim commented 1 year ago

The problem details

PHP classes are somewhat like Python classes, though with different syntax. There is a constructor function which constructs instances of the class, and this is where instance attribute (properties) are specified.

However, prior to 8.2, it was also possible to define the value of an instance variable which was not declared in the constructor. The error message above noticed that $status was used as a property (instance variable) of the Dal class but was NOT declared as an instance variable in the constructor.

Luckily, this problem is easily fixed by declaring, in the constructor function of the Dal class, that $status is an instance variable (public $status;).

This kind of change was made in several php modules, as detailed in comments below.

funderburkjim commented 1 year ago

csl-websanlexicon modules

The above commit message shows the details. The modules changed were:

funderburkjim commented 1 year ago

csl-apidev

Several similar changes required so simple-search works with php 8.2