LukeTowers / oc-easyfacebookfeed-plugin

OctoberCMS plugin to display a feed of posts from a Facebook page
Other
2 stars 3 forks source link

Does not work with with PHP 7.4 #4

Open tobias-kuendig opened 4 years ago

tobias-kuendig commented 4 years ago

October 465 Plugin 1.0.5 PHP 7.4.5

After a fresh plugin installation, when visiting:

/backend/luketowers/easyfacebookfeed/feeds/create

the following exception is thrown. Switching to PHP 7.3 fixes this issue.

image

[2020-05-01 08:34:15] dev.ERROR: ErrorException: Trying to access array offset on value of type null in /<dir>/plugins/luketowers/easyfacebookfeed/models/feed/field.4help_longtoken.htm:11
Stack trace:
#0 /<dir>/plugins/luketowers/easyfacebookfeed/models/feed/field.4help_longtoken.htm(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#2 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\Controller->makeFileContents()
#3 /<dir>/modules/backend/widgets/form/partials/_field_partial.htm(7): Backend\Classes\Controller->makePartial()
#4 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#5 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#6 /<dir>/modules/backend/widgets/Form.php(275): Backend\Classes\WidgetBase->makePartial()
#7 /<dir>/modules/backend/widgets/form/partials/_field.htm(22): Backend\Widgets\Form->renderFieldElement()
#8 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#9 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#10 /<dir>/modules/backend/widgets/form/partials/_field-container.htm(8): Backend\Classes\WidgetBase->makePartial()
#11 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#12 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#13 /<dir>/modules/backend/widgets/form/partials/_form_fields.htm(2): Backend\Classes\WidgetBase->makePartial()
#14 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#15 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#16 /<dir>/modules/backend/widgets/form/partials/_form_tabs.htm(52): Backend\Classes\WidgetBase->makePartial()
#17 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#18 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#19 /<dir>/modules/backend/widgets/form/partials/_section.htm(26): Backend\Classes\WidgetBase->makePartial()
#20 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#21 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#22 /<dir>/modules/backend/widgets/form/partials/_form.htm(7): Backend\Classes\WidgetBase->makePartial()
#23 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#24 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#25 /<dir>/modules/backend/widgets/form/partials/_form-container.htm(8): Backend\Classes\WidgetBase->makePartial()
#26 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#27 /<dir>/modules/system/traits/ViewMaker.php(97): Backend\Classes\WidgetBase->makeFileContents()
#28 /<dir>/modules/backend/widgets/Form.php(228): Backend\Classes\WidgetBase->makePartial()
#29 /<dir>/modules/backend/behaviors/FormController.php(416): Backend\Widgets\Form->render()
#30 [internal function]: Backend\Behaviors\FormController->formRender()
#31 /<dir>/vendor/october/rain/src/Extension/ExtendableTrait.php(411): call_user_func_array()
#32 /<dir>/modules/backend/classes/Controller.php(184): Backend\Classes\Controller->extendableCall()
#33 /<dir>/plugins/luketowers/easyfacebookfeed/controllers/feeds/create.htm(13): Backend\Classes\Controller->__call()
#34 /<dir>/modules/system/traits/ViewMaker.php(247): include('<dir>...')
#35 /<dir>/modules/system/traits/ViewMaker.php(109): Backend\Classes\Controller->makeFileContents()
#36 /<dir>/modules/backend/classes/Controller.php(419): Backend\Classes\Controller->makeView()
#37 /<dir>/modules/backend/classes/Controller.php(296): Backend\Classes\Controller->execPageAction()
#38 /<dir>/modules/backend/classes/BackendController.php(165): Backend\Classes\Controller->run()
#39 [internal function]: Backend\Classes\BackendController->run()
#40 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array()
#41 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction()
#42 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\Routing\ControllerDispatcher->dispatch()
#43 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\Routing\Route->runController()
#44 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Route->run()
#45 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#46 /<dir>/modules/backend/classes/BackendController.php(68): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#47 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(131): Backend\Classes\BackendController->Backend\Classes\{closure}()
#48 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#49 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#50 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Routing\Middleware\SubstituteBindings->handle()
#51 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#52 /<dir>/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#53 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#54 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#55 /<dir>/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#56 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Session\Middleware\StartSession->handle()
#57 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#58 /<dir>/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#59 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#60 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#61 /<dir>/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#62 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Cookie\Middleware\EncryptCookies->handle()
#63 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#64 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#65 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\Pipeline\Pipeline->then()
#66 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->runRouteWithinStack()
#67 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\Routing\Router->runRoute()
#68 /<dir>/vendor/october/rain/src/Router/CoreRouter.php(20): Illuminate\Routing\Router->dispatchToRoute()
#69 /<dir>/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): October\Rain\Router\CoreRouter->dispatch()
#70 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#71 /<dir>/plugins/offline/speedy/classes/middleware/CDNMiddleware.php(40): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#72 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): OFFLINE\Speedy\Classes\Middleware\CDNMiddleware->handle()
#73 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#74 /<dir>/plugins/offline/speedy/classes/middleware/Http2Middleware.php(38): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#75 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): OFFLINE\Speedy\Classes\Middleware\Http2Middleware->handle()
#76 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#77 /<dir>/plugins/offline/responsiveimages/classes/ResponsiveImagesMiddleware.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#78 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): OFFLINE\ResponsiveImages\Classes\ResponsiveImagesMiddleware->handle()
#79 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#80 /<dir>/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#81 /<dir>/vendor/october/rain/src/Foundation/Http/Middleware/CheckForMaintenanceMode.php(24): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#82 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): October\Rain\Foundation\Http\Middleware\CheckForMaintenanceMode->handle()
#83 /<dir>/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#84 /<dir>/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}()
#85 /<dir>/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then()
#86 /<dir>/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#87 /<dir>/index.php(43): Illuminate\Foundation\Http\Kernel->handle()
#88 /home/offline/.config/composer/vendor/cpriego/valet-linux/server.php(232): require('<dir>...')
#89 {main}
tobias-kuendig commented 4 years ago

Possible fix:

            <?php
                $url = "https://graph.facebook.com/v3.3/oauth/access_token?grant_type=fb_exchange_token&client_id={app_id}&client_secret={app_secret}&fb_exchange_token={temporary_token}";

-                if ($formModel->credentials['app_id']) {
+                if ($formModel->credentials && $formModel->credentials['app_id']) {
                    $url = str_replace('{app_id}', $formModel->credentials['app_id'], $url);
                }

-                if ($formModel->credentials['app_secret']) {
+                if ($formModel->credentials && $formModel->credentials['app_secret']) {
                    $url = str_replace('{app_secret}', $formModel->credentials['app_secret'], $url);
                }

                 if ($formModel->_temporary_token) {
                    $url = str_replace('{temporary_token}', $formModel->_temporary_token, $url);
                }
            ?>