Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Media: Setting featured image doesn't work due to memory error #8932
We're running a blog with a high number of pictures. Trying to attach a featured image to a post in the iOS-Wordpress-App causes an error. The reason for this error is the abnormal high amount of memory the process on the server needs while trying to load the media.
The Android-app works perfectly with the exact same blog and the same user.
Steps to reproduce
What I expected
Thumbnails of my photos to pick one for upload
What happened instead
An error occurs, stating that a problem occured while trying to access my media. I don't know the exact english wording since I use the german app (see screenshot below).
App Version / OS version
Wordpress 9.5 // iOS 11.2.2
Context / Source
At 128 MB of maximum allowed memory, the server logs look like this while trying to attach a featured image using the iPhone app:
For comparison, here are the logs of the same process using the Android app:
As you can see, the Android app causes the xmlrpc to use less memory. So we tried to increase the max allowed memory to 256 on our server. The result, this time including user agent data for your documents:
[21/Mar/2018:11:36:26 +0100] "POST /xmlrpc.php HTTP/1.1" 500 169 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C202 wp-iphone/9.5" runtime=944321 php_memory=268435456
As you can see, even 256 MB are not enough. This is a major problem for us, since the only solution without an update of the iOS app would mean archiving or deleting the main part of our images.
referenced this issue
Mar 21, 2018
I can't edit my Issue since it was moved, but we've got additional information on the cause of the problem.
Take a look at how the wp.getMediaLibrary function works when using the iOS-app.
and compare it to the function when using the Android app:
The number of images that gets returned is limited to 48 when using the Android app. This filter is not set in the iOS version of the app. We think that is what causes the error described above.
i changed the default value of the wp-includes/class-wp-xmlrpc-server.php file in line 4288 from -1 to 128.
The app now works as desired
Hi @lingej apologies about the misunderstanding, lets try to clarify a few issues here:
Re reading the logs this is what I can see:
That might explain why the server is accepting the featured image from Android but not from iOS. Can you try changing the iOS app settings and re-uploading an image? Me->App Settings->Max Image Upload Size.
Can you tell me more about the rationale behind the change on
Hi @elibud ,
I'll try to clarify the problem:
When setting the featured image on the Android app, the request contains a filter (in contrast to the IOS version) which limits the number of pictures loaded from the database to 48. Remember, the iOS app basically tells the server "show me every image ever stored in the database", which causes the process to use so much memory. The Android app utilizes this filter instead. This is why the process caused by the Android app uses only 23 MB, as you can see in the logs. Again, this is not related to the picture size, but shows the memory used by the process the apps starts on the server.
Just to sum things up:
The solution of the problem:
What we did was just a workaround that will be overwritten once we install the next wordpress update (and won't help any other users that face the same problem.)