encomage / module-guestbook

Encomage Guestbook module for Magento 2
1 stars 1 forks source link

Undefined offset #1

Closed gewaechshaus closed 5 years ago

gewaechshaus commented 5 years ago

Hey @VadimSapa ,

as soon as I want to display an answer while clicking on the related button, I got an undefined offset error on the ajax/answer controller:

Exception #0 (Exception): Notice: Undefined offset: 5646 in /var/www/html/app/code/Encomage/GuestBook/Api/SearchResults.php on line 42

https://github.com/encomage/module-guestbook/blob/df775f8454f95b8b4f9021f69798fbceed47afad/Api/SearchResults.php#L42

MOS 2.2.6

Cheers Jan

andrey-bondarenko commented 5 years ago

Hi, @gewaechshaus thanks! We will investigate this issue asap

gewaechshaus commented 5 years ago

@andrey-bondarenko - many thanks! Meanwhile I am trying to understand the _putToArray method :) You can reproduce it even by

$this->_putToArray($this->_arrayTree[1], $pathPieces, $items);

andrey-bondarenko commented 5 years ago

@gewaechshaus can you please provide the dump of your guest_book table? Thanks

gewaechshaus commented 5 years ago

For sure

--
-- Tabellenstruktur für Tabelle `guest_book`
--

CREATE TABLE `guest_book` (
  `message_id` int(11) NOT NULL COMMENT 'Message ID',
  `store_id` int(11) NOT NULL COMMENT 'Store ID',
  `reply_path` text COMMENT 'Reply Path',
  `city` varchar(100) DEFAULT NULL COMMENT 'Ort',
  `customer_id` int(11) DEFAULT NULL COMMENT 'Customer ID',
  `status` smallint(6) DEFAULT NULL COMMENT 'Status',
  `message` text COMMENT 'Message',
  `name` text COMMENT 'Name',
  `subject` varchar(50) DEFAULT NULL COMMENT 'Subject',
  `email` varchar(50) DEFAULT NULL COMMENT 'Email',
  `session_id` varchar(255) DEFAULT NULL COMMENT 'Session ID',
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Created At',
  `updated_at` timestamp NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP COMMENT 'Updated At',
  `customer_review` smallint(6) DEFAULT NULL COMMENT 'Customer Reviews',
  `admin_answer` text COMMENT 'Admin Answer'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Guest Book Table';

--
-- Daten für Tabelle `guest_book`
--

INSERT INTO `guest_book` (`message_id`, `store_id`, `reply_path`, `city`, `customer_id`, `status`, `message`, `name`, `subject`, `email`, `session_id`, `created_at`, `updated_at`, `customer_review`, `admin_answer`) VALUES
(1, 1, NULL, 'Wuppertal', 0, 2, 'This is just a bit of samba.', 'Jan de Tester', NULL, 'test@anymaildomain.com', NULL, '2019-04-03 14:48:13', '2019-04-03 14:52:08', 5, 'Admin Answer'),
(2, 2, '1', 'Köln', 0, 2, 'Test-Antwort', 'Max de Tester', NULL, 'max@makethingsnotwar.com', NULL, '2019-04-03 14:50:13', '2019-04-03 14:50:39', 5, NULL),
(3, 2, '1', 'Düsseldorf', 0, 3, 'Rejected Answer', 'Jan de Tester', NULL, 'spam@gewaechshaus.eu', NULL, '2019-04-03 14:51:17', '2019-04-03 14:51:34', NULL, NULL);
andrey-bondarenko commented 5 years ago

@gewaechshaus I have installed your table, but I haven't problems with it. http://prntscr.com/n6zers

Do you have any customization?

gewaechshaus commented 5 years ago

@andrey-bondarenko - yes, I added the field city and removed subject...

gewaechshaus commented 5 years ago

@andrey-bondarenko - Even with the module and the table reinstalled I am running into this error. Developer mode, Magento OS 2.2.6 using php7.1-fpm(7.1.27)... Using http2 protocol.

Damn

gewaechshaus commented 5 years ago
gewaechshaus commented 5 years ago
1 exception(s):
Exception #0 (Exception): Notice: Undefined offset: 1 in /var/www/html/vendor/encomage/module-guestbook/Api/SearchResults.php on line 42

Exception #0 (Exception): Notice: Undefined offset: 1 in /var/www/html/vendor/encomage/module-guestbook/Api/SearchResults.php on line 42
#0 /var/www/html/vendor/encomage/module-guestbook/Api/SearchResults.php(42): Magento\Framework\App\ErrorHandler->handler(8, 'Undefined offse...', '/var/www/html/v...', 42, Array)
#1 /var/www/html/vendor/encomage/module-guestbook/Block/Comments/Answer.php(95): Encomage\GuestBook\Api\SearchResults->asTree()
#2 /var/www/html/vendor/encomage/module-guestbook/Controller/Ajax/Answer.php(73): Encomage\GuestBook\Block\Comments\Answer->getAnswerHtml()
#3 /var/www/html/generated/code/Encomage/GuestBook/Controller/Ajax/Answer/Interceptor.php(24): Encomage\GuestBook\Controller\Ajax\Answer->execute()
#4 /var/www/html/vendor/magento/framework/App/Action/Action.php(107): Encomage\GuestBook\Controller\Ajax\Answer\Interceptor->execute()
#5 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#6 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Encomage\GuestBook\Controller\Ajax\Answer\Interceptor->___callParent('dispatch', Array)
#7 /var/www/html/vendor/mgtcommerce/module-mgtdevelopertoolbar/src/app/code/Mgt/DeveloperToolbar/Model/App/FrontController/ToolbarPlugin.php(64): Encomage\GuestBook\Controller\Ajax\Answer\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#8 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Mgt\DeveloperToolbar\Model\App\FrontController\ToolbarPlugin->aroundDispatch(Object(Encomage\GuestBook\Controller\Ajax\Answer\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#9 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Encomage\GuestBook\Controller\Ajax\Answer\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#10 /var/www/html/generated/code/Encomage/GuestBook/Controller/Ajax/Answer/Interceptor.php(39): Encomage\GuestBook\Controller\Ajax\Answer\Interceptor->___callPlugins('dispatch', Array, Array)
#11 /var/www/html/vendor/magento/framework/App/FrontController.php(55): Encomage\GuestBook\Controller\Ajax\Answer\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#12 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#13 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#14 /var/www/html/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#15 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#16 /var/www/html/vendor/mirasvit/module-cache-warmer/src/CacheWarmer/Plugin/Debug/OnHitPlugin.php(107): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#17 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Mirasvit\CacheWarmer\Plugin\Debug\OnHitPlugin->aroundAroundDispatch(Object(Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor), Object(Closure), Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#18 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#19 /var/www/html/generated/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin/Interceptor.php(26): Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->___callPlugins('aroundDispatch', Array, NULL)
#20 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin\Interceptor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#21 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#22 /var/www/html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#23 /var/www/html/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#24 /var/www/html/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
#25 /var/www/html/vendor/magento/framework/App/Bootstrap.php(257): Magento\Framework\App\Http\Interceptor->launch()
#26 /var/www/html/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#27 {main}
gewaechshaus commented 5 years ago

I can't figure out why $this->_arrayTree is empty in my case, have to continue debugging tomorow.

gewaechshaus commented 5 years ago

TADAA... Found it - tricky shit. I am sorting DESC instead of ASC (so you have to configure the module the same way to reproduce the issue). This results in an empty object cause the ELSE condition https://github.com/encomage/module-guestbook/blob/df775f8454f95b8b4f9021f69798fbceed47afad/Api/SearchResults.php#L37 is running before the IF condition which inserts the indexes/values into the array. It could be so simple :) Had to go with easiest echo debugging to check this. Fuck.

https://github.com/encomage/module-guestbook/blob/7524fad73529d45f43cc44eb603e8159e2d39968/Block/Comments/Answer.php#L121

gewaechshaus commented 5 years ago

Quickfix https://github.com/gewaechshaus/module-guestbook/blob/master/Api/SearchResults.php

andrey-bondarenko commented 5 years ago

@gewaechshaus Hi, we'll continue to investigate it today.

andrey-bondarenko commented 5 years ago

@gewaechshaus

We have fixed this issue. Please update the extension.

Tested on default configuration in Magento 2.2.6

Thanks

gewaechshaus commented 5 years ago

@andrey-bondarenko - Just saw the commit... Many thanks. Next step would be to fix the pagination. I also fixed some ajax request loader related stuff here https://github.com/gewaechshaus/module-guestbook/commits/master

andrey-bondarenko commented 5 years ago

@gewaechshaus

Thanks! Can you create pull request?

Today we will investigate the pagination issue.

gewaechshaus commented 5 years ago

Yes, for sure...

Ok, sound nice and again many thanks for taking this issues serious and providing fixes.

andrey-bondarenko commented 5 years ago

@gewaechshaus Thanks for using our extension 👍