• Resolved cjhaas

    (@chrisvendiadvertisingcom)


    When running PHP7 with full debug and errors turned on we’re getting:

    The Twig_Autoloader class is deprecated and will be removed in 2.0. Use Composer instead.

    Twig is explicitly throwing a E_USER_DEPRECATED error which isn’t fatal but we like to catch these errors early on. We switched our local copy of your plugin over to composer, removed your Twig require completely and switched to createTemplate and so far haven’t had any problems. We can send a PR or patch if you’re interested.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author supsystic

    (@supsysticcom)

    Hi!

    Thank you for contacting us regarding this problem.
    It will be great if you provide us the PR or patch with code fixes.

    Thread Starter cjhaas

    (@chrisvendiadvertisingcom)

    Do you have a git repo for a PR? If not, I can temporarily add your previous version to mine and commit a patch that shows the changes.

    • This reply was modified 7 years, 10 months ago by cjhaas.
    Thread Starter cjhaas

    (@chrisvendiadvertisingcom)

    I went ahead and just did it on my repo.

    This diff (scroll all the way to the bottom to modules/tables/views/tables.php) shows the basic changes that need to be made. Instead of rendering HTML directly via $this->_twig->render() you need to first create a template via $this->_twig->createTemplate() and then render it using $template->render(). You’ve got that in two places and the changes are pretty easy.

    The bigger change is the recommendation to not use Twig_Autoloader anymore and instead use composer. The third function change in this file no longer checks for the class and assumes that the autoloader is taking care of things for us.

    https://github.com/vendi-advertising/pricing-table-by-supsystic/commit/98393b94fb86d3fc363e71dc78d1d8018809ced4#diff-f1281deca99498d1b8f81ab6c5d678ee

    In pts.php you should just add this to the top of your code:

    
        if( is_file( dirname( __FILE__ ) . '/vendor/autoload.php' ) )
        {
            require_once dirname( __FILE__ ) . '/vendor/autoload.php';
        }
    

    Lastly, after your merge you just need to run composer update once and you’ll get the most recent version of Twig 1.0 in your vendor folder.

    From WordPress’s SVN standpoint you’ll still want to check Twig in however you’ll probably want to ignore the vendor/twig/doc, ext, test folders as well as the loose files in the twig folder.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘The Twig_Autoloader class is deprecated and will be removed in 2.0.’ is closed to new replies.