Re: file upload issues with SuiteCRM V7/8 (or apache24 and php8 diff FreeBSD vs Debian)
Date: Tue, 01 Mar 2022 21:22:09 UTC
On Tue, Mar 1, 2022 at 7:55 PM Dale Scott <dalescott@shaw.ca> wrote: > > ----- Original Message ----- > > From: "Waitman Gobble" <gobble.wa@gmail.com> > > To: "freebsd-questions" <freebsd-questions@freebsd.org> > > Sent: Tuesday, March 1, 2022 9:47:05 AM > > Subject: Re: file upload issues with SuiteCRM V7/8 (or apache24 and php8 diff FreeBSD vs Debian) > > > On Tue, Mar 1, 2022 at 4:45 PM Waitman Gobble <gobble.wa@gmail.com> wrote: > >> > >> On Tue, Mar 1, 2022 at 3:50 PM Dale Scott <dalescott@shaw.ca> wrote: > >> > > >> > Is anyone using SuiteCRM on FreeBSD, and if so, did you have to do anything > >> > beyond following the installation instructions? > >> > > ... > >> > Fwiw, here is the PHP Fatal error that occurs after saving a profile picture (I > >> > presume when the page is rendered with the new image): > >> > > >> > [Tue Mar 01 08:13:13.132076 2022] [php:error] [pid 49638] [client > >> > 174.0.43.39:45460] PHP Fatal error: Uncaught TypeError: in_array(): Argument > >> > #2 ($haystack) must be of type array, null given in > >> > /usr/local/www/SuiteCRM-7.12.4/download.php:267\nStack trace:\n#0 > >> > /usr/local/www/SuiteCRM-7.12.4/download.php(267): in_array()\n#1 > >> > /usr/local/www/SuiteCRM-7.12.4/include/MVC/Controller/SugarController.php(1017): > >> > require_once('...')\n#2 > >> > /usr/local/www/SuiteCRM-7.12.4/include/MVC/Controller/SugarController.php(465): > >> > SugarController->handleEntryPoint()\n#3 > >> > /usr/local/www/SuiteCRM-7.12.4/include/MVC/Controller/SugarController.php(361): > >> > SugarController->process()\n#4 > >> > /usr/local/www/SuiteCRM-7.12.4/include/MVC/SugarApplication.php(101): > >> > SugarController->execute()\n#5 /usr/local/www/SuiteCRM-7.12.4/index.php(52): > >> > SugarApplication->execute()\n#6 {main}\n thrown in > >> > /usr/local/www/SuiteCRM-7.12.4/download.php on line 267, referer: > >> > https://suitecrm.dalescott.net/index.php?module=Users&action=DetailView&record=1 > >> > dale@whizzer:/usr/local/etc/php % > >> > > >> > and this is the offending line 267 in download.php > >> > > >> > if (in_array($row['file_ext'], $sugar_config['allowed_preview'], true)) { > >> > $showPreview = isset($_REQUEST['preview']) && $_REQUEST['preview'] === 'yes' && > >> > $mime_type !== 'text/html'; > >> > } > >> > > ... > >> > >> There's no result from (i presume) db query . > >> > >> $row['file_ext'] is null. > >> > >> $row is typically used for a db result, but i haven't looked at the code. > >> Code execution probably should make it to this block if there's no > >> query result. > >> > >> I'll check out SugarCRM I don't think i've tried this one. > >> > > -- > > Waitman Gobble > > Thanks Waitman. The original filename for my profile picture is stored in my profile record in the database "users" table, but curiously the file is renamed when stored (stored as ".../upload/1_photo"), and I haven't found an index table giving the relationship between the original filename and the stored filename. > > However, I see essentially the same PHP Fatal error after uploading a PDF file using the "Documents" feature, but in this case the record in the "documents" table contains both the original filename ("document_name" field) and the stored filename ("document_revision_id" field). > > So maybe there are two errors, but assuming SuiteCRM works on Linux, then FreeBSD is still the common cause (or rather Apache/MariaDb/PHP8 on FreeBSD is), then I'm at a loss understanding what that could be. However, with a bit more information I'll try posting to the SuiteCRM forum. > > PHP Fatal error accessing Documents after uploading PDF file: > > [Tue Mar 01 11:29:51.595046 2022] [php:error] [pid 50591] [client 162.223.103.50:11593] PHP Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /usr/local/www/SuiteCRM-7.12.4/modules/Documents/Document.php:269\nStack trace:\n#0 /usr/local/www/SuiteCRM-7.12.4/modules/Documents/Document.php(269): in_array()\n#1 /usr/local/www/SuiteCRM-7.12.4/modules/Documents/Document.php(227): Document->fill_in_additional_detail_fields()\n#2 /usr/local/www/SuiteCRM-7.12.4/data/SugarBean.php(6183): Document->fill_in_additional_list_fields()\n#3 /usr/local/www/SuiteCRM-7.12.4/include/ListView/ListViewData.php(435): SugarBean->loadFromRow()\n#4 /usr/local/www/SuiteCRM-7.12.4/include/ListView/ListViewDisplay.php(158): ListViewData->getListViewData()\n#5 /usr/local/www/SuiteCRM-7.12.4/include/MVC/View/views/view.list.php(283): ListViewDisplay->setup()\n#6 /usr/local/www/SuiteCRM-7.12.4/include/MVC/View/views/view.list.php(391): ViewList->listViewProcess()\n#7 /usr/local/www/SuiteCRM-7.12.4/include/MVC/View/SugarView.php(210): ViewList->display()\n#8 /usr/local/www/SuiteCRM-7.12.4/include/MVC/Controller/SugarController.php(432): SugarView->process()\n#9 /usr/local/www/SuiteCRM-7.12.4/include/MVC/Controller/SugarController.php(363): SugarController->processView()\n#10 /usr/local/www/SuiteCRM-7.12.4/include/MVC/SugarApplication.php(101): SugarController->execute()\n#11 /usr/local/www/SuiteCRM-7.12.4/index.php(52): SugarApplication->execute()\n#12 {main}\n thrown in /usr/local/www/SuiteCRM-7.12.4/modules/Documents/Document.php on line 269, referer: https://suitecrm.dalescott.net/index.php?module=Users&action=EditView&record=1 > dale@whizzer:~ % > > Offending line 269 from document.php > > if (in_array($row['file_ext'], $sugar_config['allowed_preview'])) { > $this->show_preview = true; I took a look at the git repo, i had needle and haystack switched around, haystack is 2nd param in in_array. (some php functions have haystack first, i guess it depended on what the weather was outside) $sugar_config['allowed_preview'] is set in include/utils.php - what do you have it set to in that file? it's only used (read) twice, once in download.php and again in your error file, modeuls/Documents/Document.php If it "runs on Linux" i put my money that php7 is running on the Linux that works. php 8 is much more picky, php 7 wouldn't cause a type error from that code. -- Waitman Gobble