statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.7k stars 508 forks source link

Blueprint/Entry/CP Bugs #10598

Open Victor-Miguel1405 opened 1 month ago

Victor-Miguel1405 commented 1 month ago

Bug description

Hi guys! I'm having some issues with the CP can someone help me? First error is happening on the blueprints. When I try to create new fields and edit the blueprint, i get some errors:

  1. Infinite loading when adding or editing a field.
  2. Error when tryng to save created or edited field; 3 Created fields just not appear. Infinite loading: image_error Error in the console: image_error2

So I just close and open again multiple times, and click to save multiple times until it finally works.

Also I'm getting a lot of errors related to saving the field. When creating an Entry for example, I get the error "Couldn't save entry", but it ends up saving it, and when I try to save it again it says that it already exists.

image_error3

Then, I decided to take a peak in the console and this was the JSON being sent in the request:

image_error4

Is this JSON correct? It looks weird.

Some more console errors:

image

Tried to delete and got this:

image

Tried again:

image

It was deleted on the first try, althought presented error.

Also having a little bug when selecting entries to delete. The bar with options just looks like this:

image_error5

Just some extra details:

-It's happening in more than one browser. Tested it on Edge and Chrome.

How to reproduce

I don't know if everyone is getting these errors, but to reproduce it just act normally, create blueprints, entrys, taxonomies, edit fields in blueprints, try to save entries and blueprints.

Logs

Magically, there's nothing in laravel logs. I caught some errors on the console of DevTools related to JS properties as you can see in the description. Reproduced all error with the laravel logs opened and nothing.

Environment

Environment
Application Name: houseTI
Laravel Version: 11.17.0
PHP Version: 8.3.9
Composer Version: 2.7.7
Environment: production
Debug Mode: ENABLED
URL: www.houseti.com.br
Maintenance Mode: OFF
Timezone: America/Sao_Paulo
Locale: pt_BR

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: smtp
Queue: database
Session: database

Statamic
Addons: 10
Sites: 1
Stache Watcher: Enabled
Static Caching: half
Version: 5.19.0 Solo

Statamic Addons
aerni/font-awesome: 3.0.1
aryehraber/statamic-captcha: 1.12.1
dryven/faviconator: 1.3.1
eminos/statamic-iconify: 1.3.0
eminos/statamic-tabs: 1.2.0
ndx/statamic-bard-color-picker: 2.0.0
o1y/statamic-flexible-width: 1.0.1
studio1902/statamic-peak-browser-appearance: 3.5.0
studio1902/statamic-peak-seo: 8.15.3
studio1902/statamic-peak-tools: 3.4.3

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

duncanmcclean commented 1 month ago

Hmm, I'm not sure what's happening. No one else has reported these issues before 🤔

What does your app/Providers/AppServiceProvider.php file look like? Are you calling Json::withoutWrapping() anywhere?

Victor-Miguel1405 commented 1 month ago

My AppServiceProvider.php :::

<?php

namespace App\Providers;

use App\Markdown\SpanExtension;
use App\Rules\Fqdn;
use DeviceDetector\DeviceDetector;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\ServiceProvider;
use Request;
use Statamic\Facades\Markdown;
use Statamic\Statamic;
use Studio1902\PeakSeo\Handlers\ErrorPage;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Statamic::vite('app', [
            'resources/css/cp.css',

        ]);

        ErrorPage::handle404AsEntry();

        Markdown::addExtension(fn () => new SpanExtension('|'));

        $this->bootValidator();

        $this->bootMacros();
    }

    public function bootValidator()
    {
        $rules = [
            'fqdn' => Fqdn::class,
        ];

        foreach ($rules as $name => $class) {

            $rule = new $class;

            $extension = static function ($attribute, $value) use ($rule) {

                return $rule->passes($attribute, $value);
            };

            $this->app['validator']->extend($name, $extension, $rule->message());

        }

    }

    public function bootMacros()
    {
        Request::macro('device', function (): ?DeviceDetector {
            /** @var Request $self */
            $self = $this;
            $cache = cache()->driver('array');

            return $cache->rememberForever('request-device-'.spl_object_id($self), function (): DeviceDetector {
                $device = new DeviceDetector(request()->userAgent());
                $device->parse();

                return $device;
            });

        });

        Http::macro('whatsapp', function (): PendingRequest {
            return Http::withToken(Config::get('whatsapp.authToken'))
                ->throw()
                ->baseUrl('https://graph.facebook.com/v20.0/')
                ->withOptions(['phoneId' => Config::get('whatsapp.phoneId')]);
        });
    }
}

No, not calling Json::withoutWrapping() anywhere image

duncanmcclean commented 1 month ago

Okay, that all looks fine. 🤔

Are you able to give us access to the repository so we can take a look? Are you able to replicate the issue on a fresh Statamic install?

Victor-Miguel1405 commented 1 month ago

Could I send you my repository in private in .zip ? My project is not here in github, it's in my company private repository. I'll try to replicate it on a fresh install as soon as I can. Probably I'll not be able to replicate it. Didn't see anybody with the same issue . Just some extra information, I was doing the project on Statamic 4 and laravel 10. I updated everything mid project.

duncanmcclean commented 1 month ago

Sure. You can send it to support@statamic.com.

duncanmcclean commented 1 month ago

Hmm, strangly enough, even using the site you sent over, I'm not seeing any of the issues you pointed out.

Adding/editing fields in blueprints and fieldsets work as expected. Saving entries works as expected (the payload is valid JSON, unlike the screenshot you provided). The actions on the listing table are showing correctly.

I'm also not seeing any errors in my browser console or in the Laravel log file.

Do these issues happen locally for you, or only on production?