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

Known > 0.9.9 Micropub of Photo issues #13

Closed
cdn opened this issue Oct 8, 2018 · 22 comments
Closed

Known > 0.9.9 Micropub of Photo issues #13

cdn opened this issue Oct 8, 2018 · 22 comments

Comments

@cdn
Copy link
Contributor

cdn commented Oct 8, 2018

While trying to do this:

Use the micro.blog apps (macOS/iOS) to create a post with an image on Known

I encountered this error:

Photo post is created, image does not show

Some other notes:

Uploaded images seem to be cycled twice through the system, since the url passed to uploadFromUrl() includes the known blog url, and notably no file extension which leads to MIME fun (a blank $mimetype)

This has a couple of solutions: mime_content_type($tmpname); or @cleverdevil’s use of finfo_open()

Give us some context:

  • It'd also be really handy if you could tell us the contents of your version.known file
    0.9.9 2018032701 / 0.9.9-a 2018041302
  • What database are you using? (e.g. mongo, mysql, postgres)
    postgres

I see other odd things in /var/log/nginx/error.log like :

notice - PHP [8] Undefined variable: entity in /<webroot>/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:128" while reading response header from upstream

Which pertains to:

https://github.com/idno/Known/blob/master/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php#L128

@mapkyca
Copy link
Member

mapkyca commented Oct 8, 2018

You could try the latest github, I'm pretty sure there were some photos/micropub things added more recently than that.

@cdn
Copy link
Contributor Author

cdn commented Oct 8, 2018

Image is added into the post html idno/known#2138 (previously restricted to an image that was part of a check–in, hence the error.log: notice - PHP [8] Undefined variable: place_name in /<webroot>/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:317

@mapkyca
Copy link
Member

mapkyca commented Nov 9, 2018

Hmm... it looks like the endpoint already attempts to derive a mime type if the file upload doesn't provide one...

Do you have a capture of what micro.blog sends? I've signed up for an account, but not had time to really get into it and it's not immediately obvious how to send a post to my blog.

@cdn
Copy link
Contributor Author

cdn commented Nov 9, 2018

I’m having my own issues at the moment, between different domain names.

However, you would have to add your blog URL to the Wordpress or compatible blog section so that micro.blog’s app can authorise itself to/with Known.

@mapkyca
Copy link
Member

mapkyca commented Nov 11, 2018

Might try idno/known#2265 once it has been merged.

@mapkyca
Copy link
Member

mapkyca commented Nov 12, 2018

... Now merged, lmk if this resolves your problem

@cdn
Copy link
Contributor Author

cdn commented Nov 12, 2018

There’s still two runs through with upload from a blog URL, had to add blog URL to /etc/hosts since server could not resolve itself.

Eventual post does have an editable image.

@mapkyca
Copy link
Member

mapkyca commented Nov 16, 2018

I'm not sure I'm seeing a double run through... Hmm

Would be handy to see a capture of the post request...

@cdn
Copy link
Contributor Author

cdn commented Nov 16, 2018

I believe the double run is within the endpoint code, it uses uploadfromURL() (or whatever the function is actually called).

I tried to get a proxy in place to observe Micro.blog posting on macOS…

@jeremycherfas
Copy link

I believe this is the same problem as I reported on idno/known#2267

@cdn
Copy link
Contributor Author

cdn commented Nov 19, 2018

@mapkyca I tried to add in the debug line from idno/known#2273 (plus a couple of my own to illustrate)

Result:

2018/11/19 18:25:04 [error] 31437#31437: *164898 FastCGI sent in stderr: "PHP message: Known (definitely.cz): debug - MicroPub endpoint pinged: Array
PHP message: Known (definitely.cz): debug - (
PHP message: Known (definitely.cz): debug - )
PHP message: Known (definitely.cz): debug -
PHP message: Known (definitely.cz): notice - PHP [8] Undefined variable: entity in /home/cn/web/public-099a/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:133" while reading response header from upstream, client: 195.99.224.9, server: definitely.cz, request: "POST /micropub/endpoint HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "definitely.cz"
2018/11/19 18:25:09 [error] 31437#31437: *164898 FastCGI sent in stderr: "PHP message: Known (definitely.cz): debug - MicroPub endpoint pinged: Array
PHP message: Known (definitely.cz): debug - (
PHP message: Known (definitely.cz): debug - [content] => On the way to 4MWh
PHP message: Known (definitely.cz): debug - [name] =>
PHP message: Known (definitely.cz): debug - [h] => entry
PHP message: Known (definitely.cz): debug - [photo] => https://definitely.cz/file/35b68aa733c2154ba25fd87498bfbdbf
PHP message: Known (definitely.cz): debug - )
PHP message: Known (definitely.cz): debug -
PHP message: Known (definitely.cz): debug - microPub 262 image URI passed: https://definitely.cz/file/35b68aa733c2154ba25fd87498bfbdbf
PHP message: Known (definitely.cz): notice - PHP [8] Undefined index: extension in /home/cn/web/public-099a/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:607
PHP message: Known (definitely.cz): notice - PHP [8] Undefined variable: visibility in /home/cn/web/public-099a/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:407
PHP message: Known (definitely.cz): info - Pinging https://withknown.superfeedr.com/ with data hub.mode=publish&hub.url=https%3A%2F%2Fdefinitely.cz%2F,https%3A%2F%2Fdefinitely.cz%2F%3F_t%3Drss,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fphotos%2F,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fphotos%2F%3F_t%3Drss,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fall%2F,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fall%2F%3F_t%3Drss
PHP message: Known (definitely.cz): debug - Checking for HSTS headers
PHP message: Known (definitely.cz): debug - Valid HSTS found, no need to storeArray
PHP message: Known (definitely.cz): debug - (
PHP message: Known (definitely.cz): debug - [0] => HTTP/1.1 204 No Content
PHP message: Known (definitely.cz): debug - [1] => X-Powered-By: The force, Luke
PHP message: Known (definitely.cz): debug - [2] => Vary: X-HTTP-Method-Override
PHP message: Known (definitely.cz): debug - [3] => X-Superfeedr-Host: supernoder10.superfeedr.com
PHP message: Known (de

https://definitely.cz/2018/on-the-way-to-4mwh

https://definitely.cz/file/35b68aa733c2154ba25fd87498bfbdbf is uploaded (?), and used in the second request producing https://definitely.cz/file/53421427f115a552cb5688c22b3d70b8/ around line 262

@mapkyca
Copy link
Member

mapkyca commented Nov 21, 2018

Hmm....

PHP message: Known (definitely.cz): notice - PHP [8] Undefined variable: entity in /home/cn/web/public-099a/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:133" while reading response header from upstream, client: 195.99.224.9, server: definitely.cz, request: "POST /micropub/endpoint HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "definitely.cz"

This sortof implies that ->postMedia() is being called. No object is available at this point. TBH I'm not entirely sure why an event is being triggered here - seems unnecessary.

However, you're getting two loops because the first loop the client is posting the photo data (as opposed to using a url which some other clients use), this is returned and used as a url for the second event where the actual post object is created. I'll double check that this itself doesn't call an attempt to create another file from URL which would seem inefficient as it'd create two copies of files, but either way wouldn't result in duplicate photo posts.

@cdn
Copy link
Contributor Author

cdn commented Nov 21, 2018

@mapkyca I think @jeremycherfas’ is a different issue within the micropub code.
At one point it adds html to the post body which replicates the image attachment to the entity, a piece of code I commented out in the past when evaluating ownyourgram. idno/known#2267

The other side of @jeremycherfas’ coin is that any additional images attached to an Instagram post appear to go missing…

@mapkyca
Copy link
Member

mapkyca commented Nov 21, 2018

I notice the JSON payload still has the html payload which was removed elsewhere in a previous commit.

So, there are two problems: 1) You're not seeing a photo, 2) @jeremycherfas is seeing two ... ?

@cdn
Copy link
Contributor Author

cdn commented Nov 21, 2018

I see a photo, which seems to be derived from one previously uploaded.

@jeremycherfas
Copy link

I'm not sure whether the images going missing is the problem or not. My plan is to update to master later this afternoon and then post a multi-image to IG. And then see.

I haven't looked at the new debugging options yet.

@mapkyca
Copy link
Member

mapkyca commented Nov 21, 2018

@cdn the double pass appears to be normal behaviour for some clients - uploading the image first, getting a url, then passing that url in a create action. Other clients post a url which is then retrieved in a single pass.

@cdn
Copy link
Contributor Author

cdn commented Nov 21, 2018

Did a test post via PESOS/OwnYourGram with two images:

2018/11/21 12:40:07 [error] 31435#31435: *212507 FastCGI sent in stderr: "PHP message: Known (definitely.cz): debug - MicroPub endpoint pinged: Array
PHP message: Known (definitely.cz): debug - (
PHP message: Known (definitely.cz): debug - )
PHP message: Known (definitely.cz): debug -
PHP message: Known (definitely.cz): notice - PHP [8] Undefined variable: entity in /home/cn/web/public-099a/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:133" while reading response header from upstream, client: 173.230.155.197, server: definitely.cz, request: "POST /micropub/endpoint HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "definitely.cz"
2018/11/21 12:40:14 [error] 31438#31438: *212509 FastCGI sent in stderr: "PHP message: Known (definitely.cz): debug - MicroPub endpoint pinged: Array
PHP message: Known (definitely.cz): debug - (
PHP message: Known (definitely.cz): debug - [h] => entry
PHP message: Known (definitely.cz): debug - [access_token] => bbe03a6989a9eee185a27da38afd61ad
PHP message: Known (definitely.cz): debug - [content] => Inverter output, sky at noon
PHP message: Known (definitely.cz): debug - [published] => 2018-11-21T12:35:13+00:00
PHP message: Known (definitely.cz): debug - [syndication] => https://www.instagram.com/p/BqcUyoygwVn/
PHP message: Known (definitely.cz): debug - [photo] => https://definitely.cz/file/e20ec0e24fc7a0bbf4724a1302383d9b
PHP message: Known (definitely.cz): debug - )
PHP message: Known (definitely.cz): debug -
PHP message: Known (definitely.cz): warning - PHP [2] file_exists() expects parameter 1 to be a valid path, array given in /home/cn/web/public-099a/Idno/Entities/File.php:167
PHP message: Known (definitely.cz): notice - PHP [8] Undefined variable: visibility in /home/cn/web/public-099a/IdnoPlugins/IndiePub/Pages/MicroPub/Endpoint.php:407
PHP message: Known (definitely.cz): info - Pinging https://withknown.superfeedr.com/ with data hub.mode=publish&hub.url=https%3A%2F%2Fdefinitely.cz%2F,https%3A%2F%2Fdefinitely.cz%2F%3F_t%3Drss,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fphotos%2F,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fphotos%2F%3F_t%3Drss,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fall%2F,https%3A%2F%2Fdefinitely.cz%2Fcontent%2Fall%2F%3F_t%3Drss
PHP message: Known (definitely.cz): debug - Checking for HSTS headers
PHP message: Known (definitely.cz): debug - Valid HSTS found, no need to storeArray
PHP message: Known (definitely.cz): debug - (
PHP message: Known (definitely.cz): debug - [0] => HTTP/1.1 204 No Content
PHP message: Known (definitely.cz): debug - [1] => X-Powered-By: The force, Luke
PHP message: Known (definitely.cz): debug - [2] => Vary: X-HTTP-Method-Override

@mapkyca
Copy link
Member

mapkyca commented Nov 21, 2018

Ok... so you're only getting one photo, or....?

@cdn
Copy link
Contributor Author

cdn commented Nov 21, 2018

I received both images: https://definitely.cz/2018/inverter-output-sky-at-noon

@jeremycherfas should be happier with recent HEAD

And a re–run of previous ones because the ccTLD changed :o)

@mapkyca mapkyca transferred this issue from idno/known Aug 11, 2019
@cdn
Copy link
Contributor Author

cdn commented Nov 9, 2019

I suspect when a micro.blog client uses Micropub the Known code runs the else of the initial postCreate() if
if(isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') { and arrays of media URIs aren’t reduced to one when there is only one image (for example) being uploaded.

@cdn
Copy link
Contributor Author

cdn commented Nov 12, 2019

Have mostly got things working Forked extension; Micro.blog's Sunlit app is still a stumbling block, but less vital.

@cdn cdn closed this as completed Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants