Compdigitec Labs

« | Home | »

Possible crash in method_exists() with PHP 5.3

By admin | August 9, 2014

Apparently in some versions of PHP 5.3, calling method_exists() on a class which doesn’t exist seems to cause a crash. The solution, seen here, apparently involves checking class_exists() to prevent a potentially crashing call to method_exists().

This particular bug was causing the administration page of the MathJax-LaTeX WordPress plugin to be blank in the admin interface.

The trick is to replace the two lines in mathjax-latex-admin.php lines 91-92:

$wp_latex_disabled = method_exists('WP_LaTeX','init') ? "disabled='true'" : "";
$wp_latex_disabled_warning = method_exists('WP_LaTeX','init') ? "Disable wp-latex to use this syntax." : "";

with:

$wp_latex_disabled = (class_exists('WP_LaTeX', false) && method_exists('WP_LaTeX','init')) ? "disabled='true'" : "";
$wp_latex_disabled_warning = (class_exists('WP_LaTeX', false) && method_exists('WP_LaTeX','init')) ? "Disable wp-latex to use this syntax." : "";

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: PHP | 7 Comments »

7 Responses to “Possible crash in method_exists() with PHP 5.3”

  1. หนองใน Says:
    August 1st, 2025 at 21:05

    … [Trackback]

    […] Find More to that Topic: compdigitec.com/labs/2014/08/09/possible-crash-in-method_exists-with-php/ […]

  2. ไอศกรีมงานแต่ง Says:
    August 3rd, 2025 at 01:44

    … [Trackback]

    […] Read More here to that Topic: compdigitec.com/labs/2014/08/09/possible-crash-in-method_exists-with-php/ […]

  3. แทงบอลออนไลน์ Says:
    August 9th, 2025 at 19:28

    … [Trackback]

    […] Read More Information here to that Topic: compdigitec.com/labs/2014/08/09/possible-crash-in-method_exists-with-php/ […]

  4. click link Says:
    August 14th, 2025 at 23:37

    … [Trackback]

    […] Information on that Topic: compdigitec.com/labs/2014/08/09/possible-crash-in-method_exists-with-php/ […]

  5. ถมที่ดินสมุทรสงคราม Says:
    August 20th, 2025 at 02:20

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2014/08/09/possible-crash-in-method_exists-with-php/ […]

  6. สล็อตเว็บตรง Says:
    August 24th, 2025 at 21:50

    … [Trackback]

    […] Find More here to that Topic: compdigitec.com/labs/2014/08/09/possible-crash-in-method_exists-with-php/ […]

  7. th39 Says:
    August 25th, 2025 at 19:09

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2014/08/09/possible-crash-in-method_exists-with-php/ […]

Comments