amekkawi / diskusagereports

Disk Usage Reports is a web-based way to view disk usage on remote computers or servers, or to provide usage reports to users who store files on your server. Reports are stored as static JSON files which are retrieved via single HTML/AJAX web UI. No database or server-side scripting required.
http://diskusagereports.com
MIT License
67 stars 19 forks source link

Processing broken under PHP 8.1 after Ubuntu release upgrade #13

Open jheidel opened 1 year ago

jheidel commented 1 year ago

This project broke for me after migration from Ubuntu 20.04 to 22.04. I think the default PHP version was bumped from 7 to 8 as part of this upgrade which is likely responsible.

$ php -v
PHP 8.1.2-1ubuntu2.9 (cli) (built: Oct 19 2022 14:58:09) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.9, Copyright (c), by Zend Technologies

I'm getting the following error:

$ /bin/bash find.sh /data/share/downloads/ > /tmp/find.txt
$ cat /tmp/find.txt | /usr/bin/php process.php -v -vv /tmp/report
PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/jeff/sources/diskusagereports/scripts/process.php on line 286
  Processing filelist...
  Processing header...
FAIL: The header line in the <filelist> is invalid:
#

I'm no expert in php, but I found that after making the following changes I was able to get it to work:

After making these changes the report appears to be generated correctly.

cat /tmp/find.txt | /usr/bin/php process.php -v /data/media/test/report
  Processing filelist...
  Saving dir tree...
  Saving settings...
  Complete! Processed 6,762 lines from 810.04 KB, wrote 1.61 MB in 1,056 files, took 0 seconds.

I will submit these fixes as a pull request. I'm not sure if this project is still maintained but even if not hopefully this will save someone else some debugging time.