Comments (7)
I hate to bump but we're looking to finish a site in the next 10 days and without this working it's going to be a bit of a mess. If there's some alternate solution I'd love to hear about it - otherwise do you think we can expect a patch at some point?
from movabletype.
@Kagetsuki
大変ご迷惑をお掛けしております。できる限り、早急の対応を検討します。
from movabletype.
Hello,
Do you mean API as Data API? If yes, please tell me Movable Type Version.
from movabletype.
Yup, the Data API. I'm testing on 6.3.6. I have a feeling the internal code works something like this:
- if folder is set, manage file under folder (automatically generate name from title, if no title or title contains no ASCII characters set title to "post-##") ⇒ set file path and name based on folder and title (basename is not used? and automatically generated)
- if basename is set, check to make sure the base name does not conflict with folder path (path portion of base name matches folder path) ⇒ if base name conflicts with folder path ignore base name / set it to null
- permalink is generated as folder path + base name
The logic here probably made sense, because if you had folder path a/b and base name c/d/e.html, folder sorting wouldn't work correctly. The issue is there's no other attribute but base name to set the file name, and in the case of using the API you'd need to set a base name as "index" to get the apex of a folder or you'd need to set manually to some name to fit with links in other pages you're posting.
Ideally if MT would extract folders automatically from the base name, and create folders if they didn't already exist, it would not only solve this issue but would also eliminate the need to pass folder arguments (which require folder ID, meaning you need to get folders from API first and then extrapolate the ID before you can even post a page!).
Thanks for looking into this - please tell me if you need any more info.
from movabletype.
I don't work with the Data API, but I did look at the Data API code and see if anything jumped out at me. I think I discovered a bug in the basename uniqueness checking when a new page is created through the Data API.
In theory, you should be able to create multiple pages with the same basename (file name) in the same site/blog as long as each page is in a different folder. In practice, the Data API checks the entire site/blog for unique basenames without looking at any folder assignment.
From lib/MT/DataAPI/Endpoint/v2/Page.pm, lines 89-94 (MT 6.3.6):
if ( !$new_page->basename
|| $app->model('page')
->exist( { blog_id => $site->id, basename => $new_page->basename } ) )
{
$new_page->basename( MT::Util::make_unique_basename($new_page) );
}
Once a page has been created with a basename of 'index' for example, the above code does not allow for any other pages to have the same 'index' basename, even if the page is in a different folder. In this case, the Data API generates a unique basename ("post-##") instead of allowing "index".
When creating new pages in Movable Type, the MT code loads all pages with the same basename as the new page being created, constructs the permalinks to each page, and compares the existing page permalinks to the new page permalink to determine whether a duplicate basename has been used. A similar logic should be implemented in the Data API for uniqueness checking of basenames of new pages.
I don't see any workarounds for this issue in the Data API. The Data API code will need to be updated to address this issue.
@Kagetsuki - Does this seem to explain the behavior you are encountering with the Data API?
from movabletype.
Once a page has been created with a basename of 'index' for example, the above code does not allow for any other pages to have the same 'index' basename, even if the page is in a different folder. In this case, the Data API generates a unique basename ("post-##") instead of allowing "index"
I'd have to double check but that sounds dead on! Specifically line 4 of the table I made in the first post would seem to confirm this:
folder | basename | resulting folder | resulting permalink | expected result |
---|---|---|---|---|
a/b | a/b/index | a/b | a/b/a/b/index.html | a/b/index.html |
But, as I noted, permalink generation is folder + basename, so the "resulting permalink" above has the path twice, and sending the permalink as a parameter to the API just gets ignored.
Definitely hoping for a quick fix on the API. The site we're doing is a monster and importing all the pages through the admin panel by hand would probably take months... with the API we have it down to about 10 minutes!
from movabletype.
何度も投稿して大変申し訳ありませんが、ライセンス費を払っているお客様に綺麗に整理されているサイトの納品がしたいのです。 @dphillips 様が述べているようにそこまで複雑な問題ではなさそうなので、早めに対応して貰えれば大変ありがたいです。
よろしくお願い致します。
from movabletype.
Related Issues (20)
- CGI Won't Run on Ubuntu Server HOT 3
- Large ifs break entry saving (edit_entry.tmpl)
- After upgrade 4605 to 4607, a lot of search errors in Nginx logs. HOT 2
- Logging with log4perl emits warning Wide character in print HOT 1
- Page Folders don't load HOT 2
- Requierd list content field in Content Type is not requierd HOT 3
- Data API v3: POST /users, user can't sign in HOT 3
- Bug? Data API v3: GET entries endpoint has inconsistent response HOT 10
- DataAPI responses can't be cached HOT 3
- Error: Saving Entry failed: Undefined subroutine &Trackback::Entry::extract_domains called HOT 2
- Plugin development opbject_types author HOT 3
- mtapp:setting dynamic parameters fail HOT 3
- Has to Reset Password to Login HOT 2
- How to use build_file callback HOT 5
- Template Tags for Asset and Entry Counts.
- Need for greater flexibility of URL handling in templates
- Upgrade to 7.1.1 does not handle UTF8 strings correctly HOT 1
- Indicees on VARCHAR(255) break if charset "utf8mb4" is used with MariaDB HOT 1
- Sites and Entries under the menu won't show any items HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from movabletype.