Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pages fieldtype errors when single id is used #2023

Closed
lukeagsmith opened this issue Jun 15, 2018 · 9 comments

Comments

Projects
None yet
8 participants
@lukeagsmith
Copy link

commented Jun 15, 2018

Describe the bug
The fieldset editor, makes a pages fieldtype with the format parent: cf02a919-d9df-43a9-acc5-dbff19d2c942 in the YAML.

This causes a javascript 500 error in the CP when an entry with that fieldset is used and the pages selection control shows the loading spinner.

In addition, when you go back to the edit the field in the fieldset editor the parent selection is empty.

To Reproduce
Steps to reproduce the behavior:

  1. Make a field with a pages fieldtype in the fieldset editor
  2. Select a Parentpage
  3. Save fieldset
  4. Make new entry using that fieldset
  5. See spinner for field

Expected behavior
Control loads.

Workarounds

  1. Using a URL path works: parent: /path/to/page

  2. Formatting as an array works:

parent:
   - cf02a919-d9df-43a9-acc5-dbff19d2c942

Additional context
@jasonvarga posted

$parent = $this->getPage(array_get($this->config, 'parent', '/')[0]);

as a fix in PagesMode.php Line 100 but this gives an error when loading the entry edit page in the CP:

FatalThrowableError in PagesMode.php line 101:
Call to a member function uri() on null

Environment details (please complete the following information):

  • Statamic Version 2.9.8
@beckysoll

This comment has been minimized.

Copy link

commented Jul 13, 2018

Anyone found a fix for this yet?

@emlyn-Resn

This comment has been minimized.

Copy link

commented Jul 23, 2018

I'm still getting this in 2.10.2. I've patched it locally as follows, and it seems to work in my case, but I haven't looked into the root cause. Would be nice to get an official fix.

statamic/bundles/Suggest/Modes/PagesMode.php:88

protected function getPage($page)
     {
+        if( is_array($page) ) {
+            $page = reset($page);
+        }
         return Str::startsWith($page, '/') ? Page::whereUri($page) : Page::find($page);
     }

Here's the stacktrace:

[2018-07-22 10:19:22] local_win.ERROR: ErrorException: mb_strpos() expects parameter 1 to be string, array given in /app/statamic/vendor/laravel/framework/src/Illuminate/Support/Str.php:69
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'mb_strpos() exp...', '/app/statamic/v...', 69, Array)
#1 /app/statamic/vendor/laravel/framework/src/Illuminate/Support/Str.php(69): mb_strpos(Array, '/')
#2 /app/statamic/core/Data/Services/TermsService.php(69): Illuminate\Support\Str::contains(Array, '/')
#3 /app/statamic/core/Data/Services/ContentService.php(38): Statamic\Data\Services\TermsService->id(Array)
#4 /app/statamic/core/API/Content.php(28): Statamic\Data\Services\ContentService->id(Array)
#5 /app/statamic/core/API/Data.php(15): Statamic\API\Content::find(Array)
#6 /app/statamic/bundles/Relate/RelateTags.php(77): Statamic\API\Data::find(Array)
#7 /app/statamic/bundles/Relate/RelateTags.php(37): Statamic\Addons\Relate\RelateTags->getRelation(Array)
#8 /app/statamic/bundles/Relate/RelateTags.php(27): Statamic\Addons\Relate\RelateTags->collect(NULL)
#9 [internal function]: Statamic\Addons\Relate\RelateTags->index()
#10 /app/statamic/core/View/Antlers/Engine.php(163): call_user_func(Array)
#11 [internal function]: Statamic\View\Antlers\Engine::renderTag('relate', Array, '\r\n  \t\t\t\t<li><a ...', Array)
#12 /app/statamic/core/View/Antlers/Parser.php(513): call_user_func_array(Array, Array)
#13 /app/statamic/core/View/Antlers/Parser.php(260): Statamic\View\Antlers\Parser->parseCallbackTags('  \t<div class="...', Array, Array)
#14 /app/statamic/core/View/Antlers/Parser.php(109): Statamic\View\Antlers\Parser->parseVariables('<div\r\n  data-co...', Array, Array)
#15 /app/statamic/core/View/Antlers/Template.php(32): Statamic\View\Antlers\Parser->parse('<div\r\n  data-co...', Array, Array, false)
#16 /app/statamic/core/API/Parse.php(22): Statamic\View\Antlers\Template::parse('<div\r\n  data-co...', Array, Array)
#17 /app/statamic/bundles/Partial/PartialTags.php(30): Statamic\API\Parse::template('<div\r\n  data-co...', Array)
#18 [internal function]: Statamic\Addons\Partial\PartialTags->__call('index', Array)
#19 /app/statamic/core/View/Antlers/Engine.php(163): call_user_func(Array)
#20 [internal function]: Statamic\View\Antlers\Engine::renderTag('partial', Array, '', Array)
#21 /app/statamic/core/View/Antlers/Parser.php(513): call_user_func_array(Array, Array)
#22 /app/statamic/core/View/Antlers/Parser.php(113): Statamic\View\Antlers\Parser->parseCallbackTags('\r\n\r\n<section cl...', Array, Array)
#23 /app/statamic/core/View/Antlers/Template.php(32): Statamic\View\Antlers\Parser->parse('{{section:socia...', Array, Array, false)
#24 /app/statamic/core/API/Parse.php(22): Statamic\View\Antlers\Template::parse('{{section:socia...', Array, Array)
#25 /app/statamic/core/View/Antlers/Engine.php(70): Statamic\API\Parse::template('{{section:socia...', Array)
#26 /app/statamic/vendor/laravel/framework/src/Illuminate/View/View.php(147): Statamic\View\Antlers\Engine->get('/app/site/theme...', Array)
#27 /app/statamic/vendor/laravel/framework/src/Illuminate/View/View.php(118): Illuminate\View\View->getContents()
#28 /app/statamic/vendor/laravel/framework/src/Illuminate/View/View.php(83): Illuminate\View\View->renderContents()
#29 /app/statamic/vendor/laravel/framework/src/Illuminate/Http/Response.php(51): Illuminate\View\View->render()
#30 /app/statamic/core/Http/Controllers/StatamicController.php(253): Illuminate\Http\Response->setContent(Object(Illuminate\View\View))
#31 [internal function]: Statamic\Http\Controllers\StatamicController->index('highlights/moto...')
#32 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array(Array, Array)
#33 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction('index', Array)
#34 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): Illuminate\Routing\ControllerDispatcher->call(Object(Statamic\Http\Controllers\StatamicController), Object(Illuminate\Routing\Route), 'index')
#35 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#36 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#37 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#39 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#40 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(68): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(Statamic\Http\Controllers\StatamicController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'index')
#41 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'Statamic\\Http\\C...', 'index')
#42 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request))
#43 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#44 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#46 /app/statamic/core/StaticCaching/Middleware/Cache.php(30): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#47 [internal function]: Statamic\StaticCaching\Middleware\Cache->handle(Object(Illuminate\Http\Request), Object(Closure))
#48 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#49 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#50 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#51 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#52 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(674): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#53 /app/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#54 /app/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#55 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#56 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#57 /app/statamic/core/Http/Middleware/PersistStache.php(22): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#58 [internal function]: Statamic\Http\Middleware\PersistStache->handle(Object(Illuminate\Http\Request), Object(Closure))
#59 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#60 /app/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#61 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#62 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#63 /app/statamic/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#64 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#65 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#66 /app/statamic/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#67 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#68 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#69 /app/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#70 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#71 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#72 /app/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#73 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#74 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#75 /app/statamic/core/StaticCaching/Middleware/Retrieve.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#76 [internal function]: Statamic\StaticCaching\Middleware\Retrieve->handle(Object(Illuminate\Http\Request), Object(Closure))
#77 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#78 /app/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#79 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#80 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array)
#81 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#82 /app/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#83 /app/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#84 /app/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#85 /app/index.php(155): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#86 {main}  
@lukeagsmith

This comment has been minimized.

Copy link
Author

commented Oct 19, 2018

@emlyn-Resn This fix works for me too.

As you say though, would be good to get this rolled into an official release so as not to have to do this manually on every new site.

@sebszocinski

This comment has been minimized.

Copy link

commented Nov 19, 2018

+1 here getting this on 2.11.2

@gmcz

This comment has been minimized.

Copy link

commented Nov 20, 2018

@emlyn-Resn Thank you for posting this fix until the Gentlemen make it work!

@sebszocinski

This comment has been minimized.

Copy link

commented Dec 13, 2018

Any updates on this?

@jsblair9

This comment has been minimized.

Copy link

commented Feb 6, 2019

Reporting the same issue here on 2.11.9

@lukeagsmith

This comment has been minimized.

Copy link
Author

commented Mar 30, 2019

Still an issue on 2.11.10

Any chance the above fix could be added to avoid having to do this every time?

@jesseleite

This comment has been minimized.

Copy link
Member

commented Apr 26, 2019

Will be in next release. Thanks @emlyn-Resn 🤘

@jasonvarga jasonvarga closed this Apr 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.