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

Link header too long for pages with hundreds of tags #41847

Closed
katag9k opened this issue Jun 21, 2022 · 7 comments
Closed

Link header too long for pages with hundreds of tags #41847

katag9k opened this issue Jun 21, 2022 · 7 comments
Assignees
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Bug An existing feature does not function as intended

Comments

@katag9k
Copy link

katag9k commented Jun 21, 2022

Description

When editing a post that has hundreds of tags, the tags do not load in the sidebar. If you save the post in this state you lose all your tags. Most hosts limit their header length, and Link header grows with the number of tags, eventually resulting in a 503.

Step-by-step reproduction instructions

On a host with a header that is limited to 8kb.

  1. Create a post with 270 tags
  2. Save post and exit to the dashboard
  3. Click edit post again
  4. Notice that tags in the sidebar are not populated
  5. Open console and search XHR for tags note the long Link generated

link: <https://mywordpress.site.com/wp-json/wp/v2/tags?context=view&per_page=100&orderby=count&order=desc&_fields=id,name&include[0]=16352&include[1]=16386&include[2]=16531&include[3]=16571&include[4]=16574&include[5]=16721&include[6]=16912&include[7]=17072&include[8]=17078&include[9]=17269&include[10]=17304&include[11]=17305&include[12]=17411&include[13]=45680&include[14]=47938&include[15]=17483&include[16]=17503&include[17]=17524&include[18]=17636&include[19]=46130&include[20]=17661&include[21]=17688&include[22]=17786&include[23]=17823&include[24]=17855&include[25]=17948&include[26]=17970&include[27]=18044&include[28]=18096&include[29]=18102&include[30]=18129&include[31]=18219&include[32]=18253&include[33]=41188&include[34]=44099&include[35]=18428&include[36]=18455&include[37]=48484&include[38]=48486&include[39]=40496&include[40]=18514&include[41]=41187&include[42]=47000&include[43]=42831&include[44]=18625&include[45]=18664&include[46]=18665&include[47]=18681&include[48]=18736&include[49]=18783&include[50]=18912&include[51]=18938&include[52]=18945&include[53]=18982&include[54]=19011&include[55]=44301&include[56]=19042&include[57]=19056&include[58]=19065&include[59]=40019&include[60]=19170&include[61]=19193&include[62]=19202&include[63]=47064&include[64]=19256&include[65]=19321&include[66]=19333&include[67]=19387&include[68]=19409&include[69]=19428&include[70]=19476&include[71]=19503&include[72]=44396&include[73]=19525&include[74]=19585&include[75]=45534&include[76]=19627&include[77]=19632&include[78]=37632&include[79]=19810&include[80]=19853&include[81]=19854&include[82]=19863&include[83]=19958&include[84]=39678&include[85]=43776&include[86]=20065&include[87]=20156&include[88]=45946&include[89]=20229&include[90]=20231&include[91]=20242&include[92]=20302&include[93]=45330&include[94]=20391&include[95]=20421&include[96]=20437&include[97]=20465&include[98]=45753&include[99]=20475&include[100]=20476&include[101]=20477&include[102]=20482&include[103]=20495&include[104]=37651&include[105]=20638&include[106]=20805&include[107]=47740&include[108]=44731&include[109]=20860&include[110]=20959&include[111]=20975&include[112]=21000&include[113]=44733&include[114]=21248&include[115]=21257&include[116]=44732&include[117]=21413&include[118]=21424&include[119]=21427&include[120]=21492&include[121]=21585&include[122]=45810&include[123]=21636&include[124]=37687&include[125]=21648&include[126]=21650&include[127]=21691&include[128]=21698&include[129]=21717&include[130]=21738&include[131]=21740&include[132]=21761&include[133]=21825&include[134]=21831&include[135]=21909&include[136]=21973&include[137]=21974&include[138]=21998&include[139]=22002&include[140]=22015&include[141]=22101&include[142]=22107&include[143]=22110&include[144]=22146&include[145]=22193&include[146]=22220&include[147]=22249&include[148]=22285&include[149]=22297&include[150]=39677&include[151]=46840&include[152]=22357&include[153]=41611&include[154]=22394&include[155]=22404&include[156]=41697&include[157]=22572&include[158]=22719&include[159]=22737&include[160]=22743&include[161]=22749&include[162]=22847&include[163]=22869&include[164]=22886&include[165]=22927&include[166]=22933&include[167]=22972&include[168]=22989&include[169]=45963&include[170]=23295&include[171]=23358&include[172]=23681&include[173]=23686&include[174]=23716&include[175]=41964&include[176]=23736&include[177]=23743&include[178]=23768&include[179]=23818&include[180]=23857&include[181]=23947&include[182]=23970&include[183]=24013&include[184]=24014&include[185]=45945&include[186]=24028&include[187]=24066&include[188]=24119&include[189]=47936&include[190]=24160&include[191]=24195&include[192]=24329&include[193]=24422&include[194]=24423&include[195]=24525&include[196]=24591&include[197]=24620&include[198]=24621&include[199]=24733&include[200]=24754&include[201]=24781&include[202]=43021&include[203]=25010&include[204]=25032&include[205]=25033&include[206]=25123&include[207]=25178&include[208]=25199&include[209]=25215&include[210]=25218&include[211]=25231&include[212]=25239&include[213]=25310&include[214]=25318&include[215]=25339&include[216]=25375&include[217]=25472&include[218]=25537&include[219]=25568&include[220]=25585&include[221]=25775&include[222]=25834&include[223]=25842&include[224]=25949&include[225]=26009&include[226]=26091&include[227]=26138&include[228]=26141&include[229]=26219&include[230]=26363&include[231]=26460&include[232]=26478&include[233]=43773&include[234]=26497&include[235]=26643&include[236]=37908&include[237]=45262&include[238]=27081&include[239]=27088&include[240]=27118&include[241]=27119&include[242]=27122&include[243]=27198&include[244]=27227&include[245]=47937&include[246]=27256&include[247]=27284&include[248]=27295&include[249]=27400&include[250]=27403&include[251]=27430&include[252]=27446&include[253]=27476&include[254]=27539&include[255]=27549&include[256]=48485&include[257]=41612&include[258]=27592&include[259]=27749&include[260]=41939&include[261]=27781&include[262]=28127&include[263]=28145&include[264]=28207&include[265]=28208&include[266]=45322&include[267]=41695&include[268]=28261&include[269]=28327&include[270]=28412&include[271]=28471&include[272]=28529&include[273]=28561&include[274]=28602&include[275]=28619&include[276]=28631&include[277]=28642&include[278]=28684&include[279]=28747&include[280]=28797&include[281]=28852&include[282]=28949&include[283]=29016&include[284]=29145&include[285]=29179&include[286]=29200&include[287]=29215&include[288]=29280&include[289]=29296&include[290]=29433&include[291]=45009&include[292]=44394&include[293]=29497&include[294]=45263&include[295]=29594&include[296]=29639&include[297]=41696&include[298]=44395&include[299]=29678&include[300]=29724&include[301]=29770&include[302]=45772&include[303]=44470&include[304]=44126&include[305]=29912&include[306]=29959&include[307]=29984&include[308]=30062&include[309]=30076&include[310]=30095&include[311]=30221&include[312]=47001&include[313]=30260&include[314]=30275&include[315]=30309&include[316]=43222&include[317]=30473&include[318]=30474&include[319]=30476&include[320]=30494&include[321]=30611&include[322]=30675&include[323]=30726&include[324]=30903&include[325]=30908&include[326]=30918&include[327]=30955&include[328]=31003&include[329]=31005&include[330]=31085&include[331]=31154&include[332]=31170&include[333]=31172&include[334]=46353&include[335]=31209&include[336]=31218&include[337]=45961&include[338]=31411&include[339]=47711&_locale=user&page=2>

Screenshots, screen recording, code snippet

Annotation on 2022-06-21 at 15-04-13

Environment info

  • WordPress 6.0
  • Theme: twentytwentyone

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended General Interface Parts of the UI which don't fall neatly under other labels. labels Jun 22, 2022
@talldan
Copy link
Contributor

talldan commented Jun 28, 2022

It looks like this is where it happens:

const query = {
...DEFAULT_QUERY,
include: _termIds.join( ',' ),
per_page: -1,
};

It joins together all the term ids to create the query params for the REST API, which can be very very long.

I'm not sure what the right fix would be. It could be an option to introduce pagination to this UI. Or is there a way to pass the ids in the request body? cc @spacedmonkey @TimothyBJacobs

@Mamaduka
Copy link
Member

Related #41825.

@spacedmonkey
Copy link
Member

@talldan Instead of doing a query by ids, why not lookup by post id. Like this.

https://www.spacedmonkey.com/wp-json/wp/v2/categories?post=415.

Feels a lot cleaner.

@Mamaduka
Copy link
Member

Thanks for the recommendation, @spacedmonkey 🙇 That indeed feels a lot cleaner.

Do you know if it's possible to do something similar for Media (#41825)?

@spacedmonkey
Copy link
Member

Do you know if it's possible to do something similar for Media (#41825)?

Sadly no. You can do this, https://spacedmonkey.com/wp-json/wp/v2/media?post=389 but that would get all the attachments uploaded in on that post. But a gallery can be created with an attachment from any post.

We could make the url short by doing this ?includes?=1,2,3 instead of ?includes[0]=1 it should make the url a little shorter.

@Mamaduka Mamaduka self-assigned this Jun 29, 2022
@TimothyBJacobs
Copy link
Member

We could make the url short by doing this ?includes?=1,2,3 instead of ?includes[0]=1 it should make the url a little shorter.

This would require a server side change. We encode the decoded query parameters with urlencode_deep.

Ideally we probably should've set a maxItems value for include and exclude IMO and have the client do it's own pagination across the set of ids. However, I don't think we can justify that BC break. So I suppose we should advocate for clients to do it themselves even though the server can't safely enforce it.

@Mamaduka
Copy link
Member

Unfortunately, the look-up by post ID won't work for post-taxonomies. This is because the editor stores newly assigned terms in the state, and they are only persisted on save.

Ideally we probably should've set a maxItems value for include and exclude IMO and have the client do it's own pagination across the set of ids. However, I don't think we can justify that BC break. So I suppose we should advocate for clients to do it themselves even though the server can't safely enforce it.

Maybe we can introduce new middleware that can handle this on the client.

P.S. I recently found an old issue for large include argument errors, so I'm closing this one as a duplicate — original issue #11541.

@Mamaduka Mamaduka closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants