Undefined variable in oembed.php

Post

Posted
Rating:
#3770 (In Topic #741)
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’

Undefined variable: format_in_path in sources/hooks/systems/media_rendering/oembed.php on line 133

Greetings,

On a newer install with not much content I somehow have crashed the system with an error code of :

in ADMIN area:  PHP NOTICE [8] Undefined variable: format_in_path in sources/hooks/systems/media_rendering/oembed.php on line 133 (version: 10.0.12, PHP version: 7.2.1-1+ubuntu16.04.1+deb.sury.org+1, URL: /adminzone/index.php?page=admin-cleanup&type=rebuild)

main page:

PHP NOTICE [8] Undefined variable: format_in_path in sources/hooks/systems/media_rendering/oembed.php on line 133 (version: 10.0.12, PHP version: 7.2.1-1+ubuntu16.04.1+deb.sury.org+1, URL: /index.php?page=start)

History:
1. I had posted a few links to facebook pages and was surprised that the oembed did not work as usual. I ignored it and wanted to investigate in the future. 
2. Today I posted a new news item with a FB link and the system crashed. I deleted that news article.
3. I am attempting to delete the sole news article but no luck.

Since this is a new install with no content I can just restart fresh but wanted to share this as maybe it is a bug or something on my end.

Thanks much

Stevyn


 

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#3771
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
I suspect your sources/hooks/systems/media_rendering/oembed.php file has been corrupted somehow. It's very unusual for a PHP file to be corrupted in Composr, unless it was hand-edited wrongly somehow.

Anyway, re-uploading that file should fix the error.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3781
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
Hello,

I downloaded the latest zip and uploaded all files to be safe. Then cleared the caches and ran file integrity check and all checks out as good. I also did a check on the database and it says each table is OK.

I still have the error as you can see at (link removed by stevyn)

Should I post the full error report? (seen only when admin is logged in?

Thank you

Stevyn

PS: this is super low priority since the site is newish, I could just replace the database and start with a new database? or purge the news in the database?
 

Last edit: by ironfeather


———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#3782
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
It's really bizarre. I can trace that variable through the code and it's definitely defined. Maybe some weird opcode cache extension bug.

If you'd like me to debug on the server itself, please send FTP access to chris@ocproducts.com.

I'd like to track it down.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3783
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
Hello,

I should mention more details

1. I had a few news articles and some had FB links
2. Under the news I edited the inner zone page and added two FB links and for a few days they worked normally, the composr oembed would display them as they should (expanded FB feed) then suddenly it didnt work and were simply just links again.
3. I was not sure why they didnt work so I left them alone but edit the zone editor again and this time manually embedded the HTML from facebook to display a feed. THis worked but the normal links stayed as links
4. I posted a new news article and in the new article had a new facebook link, thehn everything went haywire as we see now. 

Could the manual useage of FB embed screw it up?

Thanks for helping

Stevyn

PS* I emailed you access info. Thank you


 

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#3791
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Looking at this now.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3792
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Hi,

It's fixed now, but it's definitely a bug in a PHP extension or PHP itself. Most likely Zend OpCache, which I think is undefining a variable we are using because it incorrectly thinks it won't be used again. But your server also has a couple of non-official PHP extensions which could also potentially be causing some memory corruption (msgpack, igbinary). I can't say for sure the cause.

I worked around it by rearranging the code. Arguably my rearrangement is a bit cleaner, so I don't mind doing that.

For reference here is the change I made…

Code (Diff)

diff --git a/sources/hooks/systems/media_rendering/oembed.php b/sources/hooks/systems/media_rendering/oembed.php
index 3eabb3274..6e6763fd1 100644
--- a/sources/hooks/systems/media_rendering/oembed.php
+++ b/sources/hooks/systems/media_rendering/oembed.php
@@ -112,11 +112,6 @@ class Hook_media_rendering_oembed extends Media_renderer_with_fallback
         }
 
         // Work out the full endpoint URL to call
-        $format_in_path = (strpos($endpoint, '{format}') !== false);
-        $preferred_format = 'json';
-        if ($format_in_path) {
-            $endpoint = str_replace('{format}', $preferred_format, $endpoint);
-        }
         if (strpos($endpoint, '?') === false) {
             $endpoint .= '?url=' . urlencode($url);
         } else {
@@ -130,7 +125,11 @@ class Hook_media_rendering_oembed extends Media_renderer_with_fallback
         if ((!array_key_exists('height', $attributes)) || ($attributes['height'] != '')) {
             $endpoint .= '&maxheight=' . urlencode(array_key_exists('height', $attributes) ? $attributes['height'] : get_option('oembed_max_size'));
         }
-        if (!$format_in_path) {
+        $format_in_path = (strpos($endpoint, '{format}') !== false);
+        $preferred_format = 'json';
+        if ($format_in_path) {
+            $endpoint = str_replace('{format}', $preferred_format, $endpoint);
+        } else {
             if (strpos($endpoint, '&format=') === false) {
                 $endpoint .= '&format=' . urlencode($preferred_format);
             }
 

I also noticed a simpler change worked, changing $format_in_path = (strpos($endpoint, '{format}') !== false); to $format_in_path = (strpos($endpoint, '{format}') !== false) && true;, but that was messy, I didn't like it (or understand why it could fix it).

Last edit: by Chris Graham



Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3793
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Oh yes, and I forgot to mention…

Ideally in a situation like this I'd isolate the issue down to a test case to report to PHP. However, I tried and failed to do that, so it must have been a somewhat complex issue, e.g. the optimizer kicking in after multiple calls into the code. Almost certainly someone will find and fix it in due to time though.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3815
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
Thank you very much for your help and taking the extra time to research and track it down.

The site is back up and I am excited to continue working on it.

Thanks again, you rock!

Stevyn

 

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#3972
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
Hello, sorry to bring this back up…

I just upgraded from 12 to 13 and was surprised to see that the oembed didnt work.  So did a file integrity check and got:  

These files do not match the ones bundled with your version, but claim to be newer (so these might be bug fixes someone has put here):

sources/hooks/systems/media_rendering/oembed.php

which is the fix you did…. so i removed it and uploaded the newer oembed.php from the latest 13 version and still no luck sadly…

Not sure what has happened

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top

Post

Posted
Rating:
#4058
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Oh dear (and sorry for the delayed reply).

Is it the same error message, "Undefined variable: format_in_path in sources/hooks/systems/media_rendering/oembed.php"?

Likely what has happened is that because other PHP code has changed, whatever weird PHP bug is happening has shifted. It could be some kind of memory overwrite issue in PHP, or something to do with a PHP optimiser extension, and those kinds of things are very unpredictable.

I am happy to look again. If you can get a URL for me to test case that would help (e.g. to a news post or something where this is showing). Feel free to email me.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#4073
Avatar
Standard member
ironfeather is in the usergroup ‘Well-settled’
Hello,

It works fine on my main site (different server) and none else are posting about it so I think the server I setup has some php problems....  I will try and remove all php and install fresh and see if that will fix it.

Will report back

Thank you for the help, really appreciate it.

 

———–
Publisher of IronFeather Journal since 1987.  Host of KGNU Colorado Radio for 20 years. 
Currently in Japan & decided to focus on Composr as my number one CMS.
Composr site for community of Hokkaido:  Nandalow.com
Composr site for my freelance work: Futurecode.jp
My Compsr edits : 
http://ironfeather.com/bbs/viewtopic.php?f=12&t=2862
Twitter: https://twitter.com/futurecodejp

 
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,830 members
  • Our newest member is Customcollective
Back to Top