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

Regression: Pages fieldtype with parent stopped working #1428

Closed
rrelmy opened this Issue May 19, 2017 · 7 comments

Comments

Projects
None yet
4 participants
@rrelmy

rrelmy commented May 19, 2017

This regression has been introduced in v2.5.8 or v2.5.9. v.2.5.7 was working without problems.

Expected behaviour

Pages fieldtype with a parent should show suggestions.

Actual behaviour

It is just a spinning gif.

Steps to reproduce

  1. Add a Pages field to the fieldset
  2. Watch the spinner
  3. Find a 500 Server error message in the network panel of your dev tools

Temporary workaround

Remove the parent from the fieldtype.

Server Details

Operating System: macOS / Linux

Web Server: Valet / Apache

PHP Version: 7.1

Statamic Version: 2.5.10

Updated from an older Statamic or fresh install: Update

Logs

If any logs (browser, server, or Statamic) are appropriate...

[2017-05-19 17:14:03] local.ERROR: ErrorException: mb_strpos() expects parameter 1 to be string, array given in C:\projects\suissetec\statamic\vendor\laravel\framework\src\Illuminate\Support\Str.php:393
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'mb_strpos() exp...', 'C:\\projects\\sui...', 393, Array)
#1 C:\projects\suissetec\statamic\vendor\laravel\framework\src\Illuminate\Support\Str.php(393): mb_strpos(Array, '/')
#2 C:\projects\suissetec\statamic\bundles\Suggest\Modes\PagesMode.php(17): Illuminate\Support\Str::startsWith(Array, '/')
#3 C:\projects\suissetec\statamic\bundles\Suggest\SuggestController.php(33): Statamic\Addons\Suggest\Modes\PagesMode->suggestions()
#4 [internal function]: Statamic\Addons\Suggest\SuggestController->suggestions()
@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 19, 2017

Can you post the fieldtype config?

@rrelmy

This comment has been minimized.

rrelmy commented May 19, 2017

Of course

  field_3:
    type: pages
    display: Field 3
    parent: c44d9a45-5555-41b9-beba-c2beda6131d4

c44... is the id of the / page

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 19, 2017

In statamic/bundles/Relate/RelateFieldtype's preProcess method, at line 19 just before the return statement, add this:

if ($this->is_config && $max_items == 1) {
    return $data[0];
}
@jeffmckeand

This comment has been minimized.

jeffmckeand commented May 22, 2017

Ran into the same issue, so thanks for the fix, @jasonvarga. Safe to assume this will be rolled into an upcoming update? :)

@beckysoll

This comment has been minimized.

beckysoll commented May 23, 2017

👏 👏 👏 yay for finally having a problem that has a google-able solution 👏 👏 👏

@rrelmy

This comment has been minimized.

rrelmy commented May 23, 2017

You found it via google? :-D

@beckysoll

This comment has been minimized.

beckysoll commented May 23, 2017

sure did @rrelmy

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment