Hi plugin developpers,
With Piwigo 2.5 mistic100 has implemented the new MySQL library mysqli in addition to mysql. By default, if available, Piwigo will load mysqli. There are 2 issues:
1) mysql_* functions are broken
With mysqli you can expect all functions mysql_* to be broken. They must be replaced by pwg_db_* equivalent:
mysql_query => pwg_query
mysql_fetch_row => pwg_db_fetch_row
mysql_fetch_assoc => pwg_db_fetch_assoc
mysql_insert_id => pwg_db_insert_id
mysql_num_rows => pwg_db_num_rows
mysql_real_escape_string => pwg_db_real_escape_string
2) mysql_fetch_array
Since pwg_db_fetch_array does not exist in Piwigo 2.4, some of you have used mysql_fetch_array instead. To get Piwigo 2.5 compatibility, you can simply change to pwg_db_fetch_array, but compatibility with Piwigo 2.4 will be broken. If you want to keep compatibility with both Piwigo 2.4 and Piwigo 2.5, replace mysql_fetch_array either by pwg_db_fetch_assoc or pwg_db_fetch_row.
Using mysql_fetch_array is not a good practice. Imagine the following code:
$query = ' SELECT id, name FROM '.IMAGES_TABLE.' ;'; $result = pwg_query($query); while ($row = mysql_fetch_array($result)) { // what do we have in $row? // $row[0] == $row['id'] // $row[1] == $row['name'] }
It is 99,93% sure that you use $row['id'] and you never use $row[0] in this kind of code.
With pwg_db_fetch_row you only get $row[0] and $row[1]
With pwg_db_fetch_assoc you only get $row['id'] and $row['name']
Depending on your code, use pwg_db_fetch_row or pwg_db_fetch_assoc
Thanks for reading. The full list of the technical changes in 2.5 is available there http://piwigo.org/doc/doku.php?id=dev:changes_in_2.5
Offline