statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

WP Import / Collections with `%` in slug #1813

Open jcohlmeyer opened 6 years ago

jcohlmeyer commented 6 years ago

Expected behaviour

Either collections with a date order to be ordered properly when a % sign exists in the slug or the % sign in the slug to be replaced with a - on import.

Actual behaviour

The % sign stayed in the slug / file name when imported and Statamic thought the file did not have a date, even though the file started with the date.

Removing the % and replacing it with a - fixed the issue.

Steps to reproduce

  1. Export post from Wordpress where some post contains a slug that causes the .json file to have a slug line with a % in it.
  2. Import the json into Statamic using the importer.
  3. Navigate to the collection in CP

Server Details

Operating System: Ubuntu 16

Web Server: NGINX

PHP Version: 7.1

Statamic Version: 2.8.7

Updated from an older Statamic or fresh install: Updated 2.something > .5

List of installed addons: Feed, Google Analytics, Link OG Data, Permissions, PowerTools, Sitemap VideoEmbed

Logs

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

``` [2018-02-28 12:55:58] dev.ERROR: Statamic\Exceptions\InvalidEntryTypeException: Entry date not present in a date-based entry: [collections/post/ontario%ca%bcs-most-profitable-acres.md] in /var/www/oco.dev.jrc9.ca/statamic/core/Data/Entries/Entry.php:203 Stack trace: #0 [internal function]: Statamic\Data\Entries\Entry->date() #1 /var/www/oco.dev.jrc9.ca/statamic/core/Data/DataCollection.php(81): call_user_func(Array) #2 /var/www/oco.dev.jrc9.ca/statamic/core/Data/DataCollection.php(53): Statamic\Data\DataCollection->getSortableValues('date', Object(Statamic\Data\Entries\Entry), Object(Statamic\Data\Entries\Entry)) #3 [internal function]: Statamic\Data\DataCollection->Statamic\Data\{closure}(Object(Statamic\Data\Entries\Entry), Object(Statamic\Data\Entries\Entry)) #4 /var/www/oco.dev.jrc9.ca/statamic/core/Data/DataCollection.php(63): uasort(Array, Object(Closure)) #5 /var/www/oco.dev.jrc9.ca/statamic/core/Data/Entries/Collection.php(63): Statamic\Data\DataCollection->multisort('date:desc') #6 /var/www/oco.dev.jrc9.ca/statamic/core/Http/Controllers/EntriesController.php(82): Statamic\Data\Entries\Collection->entries() #7 [internal function]: Statamic\Http\Controllers\EntriesController->get('post') #8 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array(Array, Array) #9 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction('get', Array) #10 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): Illuminate\Routing\ControllerDispatcher->call(Object(Statamic\Http\Controllers\EntriesController), Object(Illuminate\Routing\Route), 'get') #11 [internal function]: Illuminate\Routing\ControllerDispatcher->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #12 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #13 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #14 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #15 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #16 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(68): Illuminate\Routing\ControllerDispatcher->callWithinStack(Object(Statamic\Http\Controllers\EntriesController), Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'get') #17 /var/www/oco.dev.jrc9.ca/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...', 'get') #18 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): Illuminate\Routing\Route->runWithCustomDispatcher(Object(Illuminate\Http\Request)) #19 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request)) #20 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request)) #21 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #22 /var/www/oco.dev.jrc9.ca/statamic/core/Http/Middleware/CP/Authenticate.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #23 [internal function]: Statamic\Http\Middleware\CP\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure)) #24 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #25 /var/www/oco.dev.jrc9.ca/statamic/core/Http/Middleware/Outpost.php(48): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #26 [internal function]: Statamic\Http\Middleware\Outpost->handle(Object(Illuminate\Http\Request), Object(Closure)) #27 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #28 /var/www/oco.dev.jrc9.ca/statamic/core/Http/Middleware/CP/Localize.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #29 [internal function]: Statamic\Http\Middleware\CP\Localize->handle(Object(Illuminate\Http\Request), Object(Closure)) #30 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #31 /var/www/oco.dev.jrc9.ca/statamic/core/Http/Middleware/CP/DefaultLocale.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #32 [internal function]: Statamic\Http\Middleware\CP\DefaultLocale->handle(Object(Illuminate\Http\Request), Object(Closure)) #33 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #34 /var/www/oco.dev.jrc9.ca/statamic/core/Http/Middleware/CpEnabled.php(23): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #35 [internal function]: Statamic\Http\Middleware\CpEnabled->handle(Object(Illuminate\Http\Request), Object(Closure)) #36 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #37 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #38 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #39 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #40 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(674): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request)) #41 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request)) #42 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(236): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request)) #43 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request)) #44 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #45 /var/www/oco.dev.jrc9.ca/statamic/vendor/barryvdh/laravel-debugbar/src/Middleware/Debugbar.php(51): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #46 [internal function]: Barryvdh\Debugbar\Middleware\Debugbar->handle(Object(Illuminate\Http\Request), Object(Closure)) #47 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #48 /var/www/oco.dev.jrc9.ca/statamic/core/Http/Middleware/PersistStache.php(22): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #49 [internal function]: Statamic\Http\Middleware\PersistStache->handle(Object(Illuminate\Http\Request), Object(Closure)) #50 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #51 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #52 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure)) #53 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #54 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #55 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #56 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #57 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #58 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #59 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #60 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #61 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure)) #62 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #63 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #64 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure)) #65 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #66 /var/www/oco.dev.jrc9.ca/statamic/core/StaticCaching/Middleware/Retrieve.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #67 [internal function]: Statamic\StaticCaching\Middleware\Retrieve->handle(Object(Illuminate\Http\Request), Object(Closure)) #68 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #69 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(44): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #70 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure)) #71 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array(Array, Array) #72 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request)) #73 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func(Object(Closure), Object(Illuminate\Http\Request)) #74 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(122): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #75 /var/www/oco.dev.jrc9.ca/statamic/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(87): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #76 /var/www/oco.dev.jrc9.ca/index.php(155): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #77 {main} ```
jcohlmeyer commented 6 years ago

Interestingly I also get a duplicate ID warning when the collection filename has a % sign in it, however the second file (the one without the date) does not actually exist.

image