googlecloudplatform / wordpress-plugins Goto Github PK
View Code? Open in Web Editor NEWWordPress plugin for Google App Engine
License: GNU General Public License v2.0
WordPress plugin for Google App Engine
License: GNU General Public License v2.0
Hello,
I have a domain-named bucket that is proxied by Cloudflare for load-balancing.
I would like to serve images from the domain, right now I set the bucket name in the plugin settings as static.example.com
, but WP serve images as storage.googleapis.com/static.example.com/...
.
Is there a way to change that behavior?
Hi, I tried this plugin but I doesn't work as I excepted.
In my case, I would like each Wordpress user can upload their photos but others Wordpress Users can see OR access to these files. Even Wordpress administrators cannot access to the files. (That's why I don't want them is the "Wordpress Media Library")
Is there a way to do that with this plugin please?
I want to upload a new wordpress theme. When I run wordpress locally and try to upload new theme via admin UI I get the following error:
PCLZIP_ERR_BAD_FORMAT (-10) : Unable to go to the end of the archive
When I disable GAE plugin, it works nicely and theme is upload.
Hi! I want use Google Cloud Storage plugin only for uploading media to GCloud Storage. Don't want it serving images doing URL replacement when loading pages. For retrieving images directly from Storage bucket, I changed WP database wp_options > upload_url_path to my bucket URL and added read permission to allUsers there. This way, Wordpress can read media files very fast with no redirect. Please, how can I nullify the read redirect function and use the Google Cloud Storage plugin strictly for upload? (My site loads faster when using direct bucket URL on wp_options > upload_url_path)
Best regards!
I'm getting the following error every time I attempt to upload a file:
PHP Fatal error: Uncaught exception 'Google\\Cloud\\Core\\Exception\\BadRequestException' with message 'Client error:
PUT https://www.googleapis.com/upload/storage/v1/b/xxx/o?uploadType=resumable&upload_id=AEnB2Uxxxrs2ddVLKbe_jBSlOHJHudM0DGN-Ww5_4JOMbcEWjgT1g_2D226F7B1k349bjp6PZtyHFmXepDUG-YnsRoHkKgKQoPZVw` resulted in a 400 Bad Request
response:\n<title>Error 400 (Bad Request)!!1</title>\n' in /var/www/lmydir/wp-content/plugins/gcs/vendor/google/cloud/src/Core/RequestWrapper.php:232\nStack trace:\n#0 /var/www/lmydir/wp-content/plugins/gcs/vendor/google/cloud/src/Core/RequestWrapper.php(145): Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(GuzzleHttp\Exception\ClientException))\n#1 /var/www/mydir/wp-content/plugins/gcs/vendor/google/cloud/src/Core/Upload/StreamableUploader.php(71): Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request), Array)\n#2 /var/www/mydir/wp-content/plugins/gcs/vendor/google/cloud/src/Storage/WriteStream.php(66): Google\Cloud\Core\ in /var/www/mydir/wp-content/plugins/gcs/vendor/google/cloud/src/Core/RequestWrapper.php on line 232, referer: https://mydir/wp-admin/post-new.php`
Note that the upload to GCP Storage is actually successful, but due to the error Wordpress doesn't record the file as having been uploaded. I am hosting wordpress using a GCP Compute Engine VM.
Please let me know if there are any other details I can provide.
this plugin doesnt work with latest version of wordpress
The 'upload_dir' filter makes it a GCS-path. In the core wp_upload_dir function, the first time in the request it is called wp_mkdir_p checks existence of the folder on the GCS bucket. The subsequent filter calls are taken from cache in the wp_upload_dir function.
Maybe we're doing something wrong, but this first time execution of 'wp_mkdir_p' takes a very long time, 0.8 seconds often, run from a PHP7.1 GAE instance, built with this Google codelabs toturial.
This probably has to do with the StreamWrapper being much slower than the regular filesystem operations. Is this supposed to happen? Or is there any way we can get around this, or cache this check?
Thanks!
With current (at least 5.4 and 5.5) versions of WordPress and the PHP runtime (tested with php74 and the imagick extension enabled from app.yaml), and just the gcs-media-plugin enabled (not the appengine-plugin), rescaled images will not be generated even if the full-sized image successfully uploads.
This is due to assumptions in the WordPress "image editor" code that images are local files (rather than URLs / stream wrappers).
Filing this ticket here for tracking purposes, though I believe the correct fix for this issue should be made in WordPress core. I have a working patch and have submitted it to the WordPress tracker:
https://core.trac.wordpress.org/ticket/50630
Related posts:
https://wordpress.org/support/topic/thumbnails-broken-with-gcs-plugin/
https://scarff.id.au/blog/2020/wordpress-gcs-plugin-broken-thumbnails/
I have installed the plugin as per Installation guide but used this fix for "No project ID was provided" #44 (comment)
Now I am getting an error saying “The bucket does not exist, or is not writable” while setting the bucket name.
Catchable fatal error: Argument 1 passed to GuzzleHttp\Exception\RequestException::wrapException() must implement interface Psr\Http\Message\RequestInterface, instance of GuzzleHttp\Message\Request given, called in /var/www/production/wordpress/wp-content/plugins/wp-stateless/vendor/guzzlehttp/guzzle/src/RequestFsm.php on line 104 and defined in /var/www/production/wordpress/wp-content/plugins/gcs/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 48
When uploading many photos to a post with the appengine-plugin
enabled, the upload progress fails after a few images and I start getting "An error occurred in the upload. Please try again later." and "HTTP error." in the WordPress upload status pane.
In Safari, my console is showing errors like:
[Error] Failed to load resource: the server responded with a status of 403 (HTTP/2.0 403) (upload, line 0)
for URLs like https://www.fomopop.com/_ah/upload/?post=118&action=edit/AMmfu6b8oibmt[…]
Then the WordPress admin page gives me a login overlay, making me re-authenticate into the admin page.
I'm facing the same error of #38 but I'm on a GAE project.
Any idea what I could forget?
I haven't been able to track it down yet but it seems like the GCS bucket is being cleared out at some point if you activate/deactivate/reactivate the plugin
I'm having an issue with the plugin and the latest WordPress, 3.9.
I think a few others are having a similar experience:
https://wordpress.org/support/topic/activating-plug-in-gives-blank-page?replies=6#post-5523668
With the plugin activated, I just get a white screen.
Either:
or
Can you guys help us out? Thanks
I'm happily using the plugin with Wordpress 3.9, and everything is working correctly.
However, when trying to use it with WP 4.x, the uploading of files stops working. Any file I try to upload fails with a generic HTTP error
or similar.
I should note that the blog is in a subdirectory: users access it through www.mydomain.com/blog/
and also all of its files are in a subdirectory called blog
under the app's directory.
I've changed WP_HOME
and WP_SITEURL
in wp-config.php
to
define('WP_SITEURL', $protocol_to_use . $_SERVER['HTTP_HOST'] . '/blog');
define('WP_HOME', $protocol_to_use . $_SERVER['HTTP_HOST'] . '/blog');
and also edited my app.yaml
to
application: my-app
version: 1
runtime: php55
api_version: 1
handlers:
- url: /blog/(.*\.(htm|html|css|js|ico|jpg|png|gif|json))$
static_files: blog/\1
upload: blog/.*\.(htm|html|css|js|ico|jpg|png|gif|json)$
application_readable: true
- url: /blog/(.*\.(eot|svg|ttf|woff|woff2|otf))$
static_files: blog/\1
upload: blog/.*\.(eot|svg|ttf|woff|woff2|otf)$
- url: /blog/wp-admin/(.+)
script: blog/wp-admin/\1
secure: always
- url: /blog/wp-admin/
script: blog/wp-admin/index.php
secure: always
- url: /blog/wp-login.php
script: blog/wp-login.php
secure: always
- url: /blog/wp-cron.php
script: blog/wp-cron.php
login: admin
- url: /blog/xmlrpc.php
script: blog/xmlrpc.php
- url: /blog/wp-(.+).php
script: blog/wp-\1.php
- url: /blog(/.+)?/?
script: blog/index.php
- url: /.*
script: main-page/index.php
<< more handlers for stuff not under /blog >>
This configuration seems to work for everything except uploading - I've checked the server logs and all requests are handled by the correct handler. Also, uploading doesn't produce any 404 error or any request that is not handled.
For testing's sake, I've removed the prefix /blog
from all url:
lines and also reverted WP's SITE_*
variables, and then everything is working again.
Do you know what I'm doing wrong? Do you have a working example of WP 4 working under a subdirectory?
Thanks
It seems redundant, and also means that to install the plugin from the latest in the repo, they need to (a) download a ZIP of the recent project, (b) extract it, (c) create a new archive of the contents of google_appengine/*, (d) try installing into Wordpress.
Removing this subdirectory would eliminate most of these steps (user would just download the zip of the master branch from github and then import straight into WordPress)
We get "Http Error" when uploading media from WordPress to GCS. To be clear, media does get uploaded, but we still receive a 500 status code from the server.
Http response from har File.
"name": "status",
"value": "500 Internal Server Error"
WordPress Version 4.0
Production GAE. Did not test in dev.
The lines that appear to be causing the issue are in /modules/uploads.php, 195-196
$_COOKIE[$auth_cookie_name] = $auth_cookie;
$_COOKIE[LOGGED_IN_COOKIE] = $logged_in_cookie;
If these are changed to the following code, the upload works
if ( !isset($_COOKIE[$auth_cookie_name]) ) $_COOKIE[$auth_cookie_name] = $auth_cookie;
if ( !isset($_COOKIE[LOGGED_IN_COOKIE]) ) $_COOKIE[LOGGED_IN_COOKIE] = $logged_in_cookie;
Hello,
When updating the plugin to version 0.1.5 and running WordPress 5.3 the uploads stops working. I have debugged it down to an error when checking if file/dir exists in GCS. I haven't had time to dig deeper but it looks like there is some error with the path of directory.
bucketname/1%2F2019%2F11
instead of
bucketname/1/2019/11
With the php55 runtime, when this plugin exists (not even enabled), all pages are getting errors like this in the logs:
PHP Fatal error: Cannot use object of type __PHP_Incomplete_Class as array in <appengine_dir>/wordpress/wp-includes/post.php on line 2092
PHP Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
Sometimes the first loaded page will work, but then other pages will not.
Switching back to the php runtime makes things work again.
Also, while using the php55 runtime, removing this plugin also gets things working.
Note that I've tried with all other plugins disabled as well.
Using wordpress 4.1.1
Hello 👋
I run a security community that finds and fixes vulnerabilities in OSS. A researcher (@justmorpheus) has found a potential issue, which I would be eager to share with you.
Could you add a SECURITY.md
file with an e-mail address for me to send further details to? GitHub recommends a security policy to ensure issues are responsibly disclosed, and it would help direct researchers in the future.
Looking forward to hearing from you 👍
(cc @huntr-helper)
I'm using WP 4.1.
Tried to turn off "Use App Engine Email Service" option in settings, but seems this option simply doesn't work.
When I run Wordpress on GAE standard locally on dev_appserver.py, then uploading images doesn't work:
I'm thinking to change the name of this repository to something like wordpress-plugins
and move the current content into a sub directory google-app-engine
, then I will add another sub directory gcs-media
for a simpler new plugin which only hijacks the media upload feature.
I'm thinking to do it in a week or two.
Let me know if anyone has concerns.
Is it possible to configure the appengine-plugin
to use the Google Cloud Storage dynamic image resizing URLs, based on how images are being displayed?
For example, if I upload a 4000x3000px image to a post and include a "medium"-sized (max dimension of 300px) the image file served is still the original 4000x3000, but is merely scaled down with CSS.
In most cases, this feels like wasted bandwidth. Is there a way to get the image source URL to be somewhat tailored to what size it should be?
I would like to avoid having to upload thumbnail-specific copies of images.
Please consider adding a toggle in settings to deactivate the get_current_blog_id
from appearing in the URL path. Currently the asset path is composed with a /1/
after the bucket name, and that makes me a bit sad, as I don't have any need for that.
I'm not knowledgeable in WordPress plugins, but I would be glad to learn if somebody else also feels the same way. 🙂
I saw this bug when using gcs plugin with WordPress 5.7.2 (https://wordpress.org/plugins/gcs/)
I'm using php:8.0-fpm-alpine
Uncaught Google\Cloud\Core\Exception\ServiceException: cURL error 35: OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to oauth2.googleapis.com:443 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /var/www/html/wp-content/plugins/gcs/vendor/google/cloud-core/src/RequestWrapper.php:362
I tried hard to get this plugin to work. It took a lot of Googling to finally get it to work. Maybe some of these clarifications may eventually work themselves into the readme; but at the very least, it may save you some man hours.
If your plugin isn't activating or is giving you some sort of fatal error, you haven't followed all the steps probably.
The first step is to carefully read the readme. The specific issue is also addressed here by @tmatsuo. You must make a service worker and export the .json key. When you save it, you HAVE to make sure the place you deploy it in a place that isn't public. I usually will make this happen with secrets or simply put it in /etc
, if it's something easy.
The other critical step thing (that isn't mentioned on the readme)requires you to add and edit the first few lines (Lines 34-35) of your gcs.php, as explained here by @CaptainPatate.
$config = ['projectId' => 'Google Project ID'];
$storageClient = new \Google\Cloud\Storage\StorageClient($config);
The last line should already exist at Line 34 or 35, you simply just need to add the $config
inside the parentheses
The final step (which was also pretty critical), was to give the right permissions to the bucket. I created an 'allUsers' permission and created it read and write. I know it's highly advisable not to do this but unfortunately, I couldn't' find any other way. Here's a screenshot of my permissions...
This is what made it work for me. I hope this helps some of you out too.
You could run something like this from command line too set the permissions:
gsutil acl ch -u AllUsers:RW gs://example-bucket
More info on it here: https://cloud.google.com/storage/docs/gsutil/commands/acl
Mods, feel free to close the issue. However, I do think you should consider adding a little more clarification to the readme.
After updating the GCS plugin i received these two messages from my local development env.
Notice: A keyfile was given, but it does not contain a project ID. This can indicate an old and obsolete keyfile, in which case you should create a new one. To suppress this message, set suppressKeyFileNotice
to true
in your client configuration. To learn more about generating new keys, see this URL: https://cloud.google.com/iam/docs/creating-managing-service-account-keys#creating_service_account_keys in appengine/flexible/wordpress/wordpress-project/vendor/google/cloud/Core/src/ClientTrait.php on line 206
**I'm not sure what Keyfile is needed? I never needed keyfile for this project. **
Warning: Your application has authenticated using end user credentials from Google Cloud SDK. We recommend that most server applications use service accounts instead. If your application continues to use end user credentials from Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error. For more information about service accounts, see https://cloud.google.com/docs/authentication/. To disable this warning, set SUPPRESS_GCLOUD_CREDS_WARNING environment variable to "true". in
appengine/flexible/wordpress/wordpress-project/wordpress/wp-content/plugins/gcs/vendor/google/auth/src/Credentials/UserRefreshCredentials.php on line 102
I've setup my project_id to the correct project. I'm not sure why i'm seeing these messages. How can i test on my local machine?
All buckets were created in the Project and should be accessible by Service Accounts so I'm not sure why i'm suddenly getting this error.
Sorry, but it isn't an issue
i'm newer on github so i dont know where to put my question
my question is:
Is this plugin will show the add (new plugin section) in wordpress and any other functions that doesn't appear with appengine??
Plugin could not be activated because it triggered a fatal error.
Google\Cloud\Exception\GoogleException thrown
No project ID was provided, and we were unable to detect a default project ID.
When I try to activate this plugin GAE 1.6, I receive error:
Warning: require_once(google/appengine/api/urlfetch_service_pb.php): failed to open stream: No such file or directory in
/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72
Fatal error: require_once(): Failed opening required 'google/appengine/api/urlfetch_service_pb.php' (include_path='.:/usr/local/php5.4/lib/php') in
/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72
<\blockquote>
How to resolve this ?
I use WP 4.1.1
Hi got these two errors when activating the GCS Media plugin:
Warning: require_once(/Users/(...)/wordpress/wp-content/plugins/gcs-media/vendor/autoload.php): failed to open stream: No such file or directory in /Users/(...)/wordpress/wp-content/plugins/gcs-media/gcs.php on line 33
Fatal error: require_once(): Failed opening required '/Users/(...)/wordpress/wp-content/plugins/gcs-media/vendor/autoload.php' (include_path='.:/Users/(...):/Users/(...)/google-cloud-sdk/platform/google_appengine/php/sdk') in /Users/(...)/wordpress/wp-content/plugins/gcs-media/gcs.php on line 33
All went fine with the Appengine plugin.
When activating the plugin while running on a local dev_appserver, the URL redirects to HTTPS (eg. https://localhost:8080/wp-admin/plugins.php?action=activate&plugin=google_app_engine%2Fappengine.php&plugin_status=all&paged=1&s&_wpnonce=4267dbba03).
As the dev_appserver doesn't support HTTPS this prevents the plugin from being activated.
plugin triggered a fatal error as i tried to install it on wordpress.
The recommended memcached plugin: https://wordpress.org/plugins/memcached/ has a warning:
This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
@tmatsuo I left a note over in the WP plugin support comments a few days ago offering to update some documentation and perhaps help work on some features that would make the plugin less dependent on residing inside the GCP env.
If you are good with that, I'll fork the repo and get to work on it. As it happens, I just got an approved signed CLA back from Google middle of last week. So that should be on file under GEMServers LLC with me as the principle, John Teague. Or, I can copy you.
Please let me know if there is anything else I need to do and I'll follow along.
JT
I saw this log on php8:
2021/07/27 11:00:10 [error] 10#10: *18 FastCGI sent in stderr: "PHP message: PHP Warning: chmod(): Google\Cloud\Storage\StreamWrapper::stream_metadata is not implemented! in /var/www/html/wp-admin/includes/file.php on line 958" while reading response header from upstream, client: 127.0.0.1, server: , request: "POST /wp-admin/async-upload.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost", referrer: "http://localhost/wp-admin/upload.php"
to the readme in the gcs plugin
My Wordpress setup works perfectly on my local machine, with an image slider that scales and crops images to fit the full width of the browser window. This does not seem to work on App Engine with images on Cloud Storage. The slider images don't show up at all on the site. I'm using the Customizr theme slider.
All slider images get invalid URLs, like this one:
Failed to load resource: the server responded with a status of 404 (Not Found) http://lh3.ggpht.com/dQWB2UTfQKJMkQIqFBG1TL3PbgYq4GKvf88HjZdbrQQXObIGtz4rTmVkD_vfEk6EXXIm0yOGmzy2UtQv5kw3YCU4f0g-98WUrQ=s99999-c
The invalid URLs seem to be generated by the appengine-wordpress-plugin, because disabling it results in normal URLs (still invalid, though). The bad URLs only occur in context of the image slider.
After some more investigation, I have found that the theme logic sets slider width to 99999 to indicate full-width (which is not unusual). If I modify that width to a value like 9990, I get valid URLs, the images display, but they are incorrectly cropped and scaled. It would be great with a proper solution to this problem.
From wp-content/themes/customizr/inc/class-fire-init.php:
$this -> slider_full_size = array('width' => 99999 , 'height' => 500, 'crop' => true );
$this -> slider_size = array('width' => 1170 , 'height' => 500, 'crop' => true );
When I access Media library (grid mode), GCS plugin call google storage many time (each image a time).
And it's take more than 20s for showing all image in first page.
`Content-Type: application/json
x-goog-api-client: gl-php/8.0.7 gccl/1.25.1 wp-gcs/0.1.6 wp/5.7.2
GET /storage/v1/b/bucket_name/o/1%2F2021%2F09%2Fmac3-scaled.jpg?prettyPrint=false HTTP/1.1
Host: storage.googleapis.com
User-Agent: gcloud-php/1.25.1
Authorization: Bearer ...`
Image URLs created by appengine-wordpress-plugin are insecure http, even though the page is hosted on https.
Example:
The page at 'https://wp-dot-xxx-yyy-123.appspot.com/' was loaded over HTTPS, but displayed insecure content from 'http://lh4.ggpht.com/7SVmfoMBnl1kQ1su2cWZZTYQbO9KDzeuWql2TPvbnEdAS8T3N9OmUz1fv86Fws9OhoTc_7MEWjpa8MNubBHOxIJrWk4m4_NH=s99999-c': this content should also be loaded over HTTPS.
There seem to be two plugins here, but only the GCS plaugin is referenced in the tutorial
I need to get mail working and so I tried installing the appengine-plugin but it can't be activated - fails with the error
Warning: require_once(google/appengine/api/urlfetch_service_pb.php): failed to open stream: No such file or directory in /srv/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72 Fatal error: require_once(): Failed opening required 'google/appengine/api/urlfetch_service_pb.php' (include_path='.:/usr/lib/php') in /srv/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72
It looks like the appengine-plugin includes an obsolete version of GCS upload functionality so I guess they will conflict also.
Is there a way to get mail functionality today?
Hi,
When I go to Media and see the URL of an imagen i see for example this: https://storage.googleapis.com/opi-wpess-prd-storage/1/2019/06/massa-posta-WEB.jpg
and get an error but if I remove the 1 it works like charm.
Why gsc is adding this number on the URL?
Thanks!
There is no option or way through Plugin configuration to override the default Cache-Control value for uploaded assets which may impact both cost and CDN usage for static assets as they would require increasing the Cache-Control value to a higher value than default according to GCS Best practices.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.