Plugin Directory

Changeset 2434037


Ignore:
Timestamp:
12/08/2020 11:55:11 AM (5 years ago)
Author:
easycontent
Message:

Update 1.0.7

Location:
easycontent/trunk
Files:
4 added
41 edited

Legend:

Unmodified
Added
Removed
  • easycontent/trunk/app/NoticesManager.php

    r2194825 r2434037  
    55final class NoticesManager
    66{
    7     private $notices = ['success' => [], 'error' => [], 'info' => [], 'warning' => []];
     7    const TYPE_SUCCESS = 'success';
     8    const TYPE_ERROR   = 'error';
     9    const TYPE_INFO    = 'info';
     10    const TYPE_WARNING = 'warning';
    811
     12    private $notices = [
     13        self::TYPE_SUCCESS => [],
     14        self::TYPE_ERROR   => [],
     15        self::TYPE_INFO    => [],
     16        self::TYPE_WARNING => []
     17    ];
    918
    10     public function noticeTypeExists($type)
     19    private function noticeTypeExists($type)
    1120    {
    1221        return ! ( ! $type || ! is_string( $type ) || ! array_key_exists( $type, $this->notices ) );
    1322    }
    1423
    15 
    16     public function addNotice($notice, $type = 'success')
     24    public function addNotice($notice, $type = self::TYPE_SUCCESS)
    1725    {
    1826        if ( ! is_string( $notice ) ) {
     
    2634        $this->notices[$type][] = $notice;
    2735    }
    28 
    2936
    3037    public function renderNotices()
  • easycontent/trunk/app/Plugin.php

    r2355111 r2434037  
    77use EasyContent\WordPress\Db\DbController;
    88use EasyContent\WordPress\Metaboxes\MetaBoxesManager;
     9use EasyContent\WordPress\Notices\AdminNotice;
     10use EasyContent\WordPress\Notices\AdminNoticeInterface;
     11use EasyContent\WordPress\Notices\AdminNoticesService;
    912use EasyContent\WordPress\Pages\PagesManager;
    1013use EasyContent\WordPress\Rest\Actions\GetArticleDetails;
     
    4851    private $logger;
    4952
     53    /** @var AdminNoticesService $adminNoticesService */
     54    private $adminNoticesService;
     55
    5056
    5157    public function init()
     
    5460            return;
    5561        }
     62
     63        $this->adminNoticesService = new AdminNoticesService();
     64        $this->checkDatabaseIntegrity();
    5665
    5766        $this->noticesManager = new NoticesManager();
     
    291300        return "{$scheme}://{$host}";
    292301    }
     302
     303    public function getAdminNoticesService()
     304    {
     305        // Initialized in init() method
     306        return $this->adminNoticesService;
     307    }
     308
     309    private function checkDatabaseIntegrity()
     310    {
     311        if ( $this->getDatabaseController()->checkIntegrity() ) {
     312            return;
     313        }
     314
     315        add_action( 'init', function() {
     316            $easyContentAction = 'rerun-database-setup';
     317            $wpNonceAction = 'easycontent-rerun-database-setup';
     318
     319            $action = isset( $_GET['easycontent-action'] )
     320                ? (string)$_GET['easycontent-action']
     321                : '';
     322
     323            if ( $easyContentAction === $action && check_admin_referer( $wpNonceAction ) ) {
     324                $this->getDatabaseController()->clearDatabase();
     325                $this->getDatabaseController()->migrate();
     326
     327                wp_redirect( admin_url() );
     328                exit;
     329            }
     330
     331
     332
     333            $errorMessage = array_reduce( $this->getDatabaseController()->getIntegrityErrors(), function($carry, $item) {
     334                return $carry . ( $carry ? '<br>' : '' )
     335                    . '<strong>EasyContent:</strong> '
     336                    . esc_html( $item ) . '!';
     337            }, '' );
     338
     339            $url = admin_url() . '?' . http_build_query( [
     340                '_wpnonce' => wp_create_nonce( $wpNonceAction ),
     341                'easycontent-action' => $easyContentAction
     342            ], '', '&', PHP_QUERY_RFC3986 );
     343
     344            $errorMessage .= '<br>You can try to <a href="' . $url . '">rerun</a> database setup.';
     345            $errorMessage .= "<br><strong>WARNING!</strong> This action will erase all plugin's data from database!";
     346
     347            $this->getAdminNoticesService()->addAdminNotice( new AdminNotice( $errorMessage, AdminNoticeInterface::TYPE_ERROR ) );
     348        } );
     349    }
    293350}
  • easycontent/trunk/app/controllers/actions/main/Connection.php

    r2327436 r2434037  
    77use EasyContent\WordPress\Forms\Entities\ApiKeys;
    88use EasyContent\WordPress\Forms\Entities\ServerConnectionResponse;
     9use EasyContent\WordPress\NoticesManager;
    910use EasyContent\WordPress\Plugin;
    1011use EasyContent\WordPress\View;
     
    2324        $form = $formBuilder
    2425            ->add( 'public', TextType::class )
    25             ->add( 'url', UrlType::class )
    2626            ->getForm();
    2727
     
    4040                $plugin->noticesManager->addNotice( $successMessage );
    4141            } catch ( \Exception $e ) {
    42                 $plugin->noticesManager->addNotice( $e->getMessage(), 'error' );
     42                $plugin->noticesManager->addNotice( $e->getMessage(), NoticesManager::TYPE_ERROR );
    4343            }
    4444        } elseif ( count( $form->getErrors() ) > 0 ) {
    4545            foreach ( $form->getErrors() as $error ) {
    46                 $plugin->noticesManager->addNotice( $error->getMessage(), 'error' );
     46                $plugin->noticesManager->addNotice( $error->getMessage(), NoticesManager::TYPE_ERROR );
    4747            }
    4848        }
  • easycontent/trunk/app/controllers/actions/main/ImageProcessing.php

    r2189682 r2434037  
    55use EasyContent\WordPress\Controllers\Actions\BaseAction;
    66use EasyContent\WordPress\Forms\Entities\ImageProcessingSettings;
     7use EasyContent\WordPress\NoticesManager;
    78use EasyContent\WordPress\Plugin;
    89use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
     
    3233        } elseif ( count( $form->getErrors() ) > 0 ) {
    3334            foreach ( $form->getErrors() as $error ) {
    34                 $plugin->noticesManager->addNotice( $error->getMessage(), 'error' );
     35                $plugin->noticesManager->addNotice( $error->getMessage(), NoticesManager::TYPE_ERROR );
    3536            }
    3637        }
  • easycontent/trunk/app/controllers/actions/main/Import.php

    r2194825 r2434037  
    1010use EasyContent\WordPress\Forms\Handlers\RefreshAllDataFormHandler;
    1111use EasyContent\WordPress\Forms\Types\ArticlesFilterType;
     12use EasyContent\WordPress\NoticesManager;
    1213use EasyContent\WordPress\Pages\Import\ArticlesListTable;
    1314use EasyContent\WordPress\Plugin;
     
    5859            } elseif ( count( $importForm->getErrors() ) > 0 ) {
    5960                foreach ( $importForm->getErrors() as $error ) {
    60                     $plugin->noticesManager->addNotice( $error->getMessage(), 'error' );
     61                    $plugin->noticesManager->addNotice( $error->getMessage(), NoticesManager::TYPE_ERROR );
    6162                }
    6263            }
  • easycontent/trunk/app/controllers/actions/main/PublishingOptions.php

    r2189682 r2434037  
    88use EasyContent\WordPress\Forms\Handlers\RefreshAllDataFormHandler;
    99use EasyContent\WordPress\Helpers\PublishingOptionsPageHelper;
     10use EasyContent\WordPress\NoticesManager;
    1011use EasyContent\WordPress\Plugin;
    1112use Symfony\Component\Form\Extension\Core\Type\CollectionType;
     
    4445            } elseif ( count( $form->getErrors() ) > 0 ) {
    4546                foreach ( $form->getErrors() as $error ) {
    46                     $plugin->noticesManager->addNotice( $error->getMessage(), 'error' );
     47                    $plugin->noticesManager->addNotice( $error->getMessage(), NoticesManager::TYPE_ERROR );
    4748                }
    4849            }
  • easycontent/trunk/app/controllers/actions/main/Seo.php

    r2189682 r2434037  
    55use EasyContent\WordPress\Controllers\Actions\BaseAction;
    66use EasyContent\WordPress\Forms\Entities\SeoPlugin;
     7use EasyContent\WordPress\NoticesManager;
    78use EasyContent\WordPress\Plugin;
    89use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
     
    4950            } elseif ( count( $form->getErrors() ) > 0 ) {
    5051                foreach ( $form->getErrors() as $error ) {
    51                     $plugin->noticesManager->addNotice( $error->getMessage(), 'error' );
     52                    $plugin->noticesManager->addNotice( $error->getMessage(), NoticesManager::TYPE_ERROR );
    5253                }
    5354            }
  • easycontent/trunk/app/db/BaseModel.php

    r2355111 r2434037  
    3939    }
    4040
     41    public static function tableExists()
     42    {
     43        $wpdb = static::getWpdb();
     44        $tableName = static::tableName();
     45        $query = "SELECT * FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = '{$wpdb->dbname}' AND `TABLE_NAME` = '{$tableName}' LIMIT 1";
     46        return (bool)$wpdb->get_row( $query );
     47    }
    4148
    4249    public static function all()
  • easycontent/trunk/app/db/DbController.php

    r2327436 r2434037  
    1818    /** @var Plugin $plugin */
    1919    private $plugin;
     20
     21    private $integrityErrors = [];
    2022
    2123
     
    159161        delete_option( 'ec-public-api-key' );
    160162    }
     163
     164    public function getIntegrityErrors()
     165    {
     166        return $this->integrityErrors;
     167    }
     168
     169    public function checkIntegrity()
     170    {
     171        $this->integrityErrors = [];
     172
     173        $tables = [
     174            Article::class,
     175            ArticlePost::class,
     176            Category::class,
     177            WorkflowStage::class
     178        ];
     179
     180        global $wpdb;
     181
     182        foreach ( $tables as $tableClass ) {
     183            if ( ! call_user_func( [$tableClass, 'tableExists'] ) ) {
     184                $tableName = call_user_func( [$tableClass, 'tableName'] );
     185                $format = __( '`%s`.`%s` table is missing', EASYCONTENT_TXTDOMAIN );
     186                $this->integrityErrors[] = sprintf( $format, $wpdb->dbname, $tableName );
     187            }
     188        }
     189
     190        return ! $this->integrityErrors;
     191    }
    161192}
  • easycontent/trunk/app/db/phinx/Application.php

    r2189682 r2434037  
    1515
    1616        if ($version === null) {
    17             $version = '0.10.7';
     17            $version = '0.11.7';
    1818        }
    1919
  • easycontent/trunk/app/db/phinx/console/command/Migrate.php

    r2189682 r2434037  
    2525        $migrationTableName = "{$wpdb->prefix}easycontent_migration";
    2626
     27        $hostData = $wpdb->parse_db_host( $wpdb->dbhost );
     28
     29        $host = isset( $hostData[0] ) ? $hostData[0] : 'localhost';
     30        $port = isset( $hostData[1] ) ? $hostData[1] : 3306;
     31
    2732        $this->setConfig( new Config( [
    28             'paths'        => [
     33            'paths' => [
    2934                'migrations' => $migrationsPath
    3035            ],
     
    3439                'production'              => [
    3540                    'adapter' => 'mysql',
    36                     'host'    => defined( 'DB_HOST' ) ? DB_HOST : 'localhost',
    37                     'name'    => DB_NAME,
    38                     'user'    => defined( 'DB_USER' ) ? DB_USER : 'root',
    39                     'pass'    => defined( 'DB_PASSWORD' ) ? DB_PASSWORD : '',
    40                     'port'    => defined( 'DB_PORT' ) ? DB_PORT : 3306,
    41                     'charset' => defined( 'DB_CHARSET' ) ? DB_CHARSET : 'utf8'
     41                    'host'    => $host,
     42                    'name'    => $wpdb->dbname,
     43                    'user'    => $wpdb->dbuser,
     44                    'pass'    => $wpdb->dbpassword,
     45                    'port'    => $port,
     46                    'charset' => $wpdb->charset,
     47                    'collation' => $wpdb->collate,
    4248                ]
    4349            ]
  • easycontent/trunk/app/forms/entities/ApiKeys.php

    r2327436 r2434037  
    2020    protected $public;
    2121
    22     /**
    23      * @Assert\NotNull
    24      * @Assert\Type(type = "string")
    25      * @Assert\Url
    26      */
    27     protected $url;
    28 
    29 
    3022    public function __construct()
    3123    {
    3224        try {
    3325            $settings = Plugin::getInstance()->getSettings();
    34 
    3526            $this->setPublic( $settings->publicKey );
    36             $this->setUrl( Plugin::getInstance()->getRefererString() );
    3727        } catch ( \Exception $e ) { }
    3828    }
    39 
    4029
    4130    public function getPublic()
     
    4837        $this->public = $key;
    4938    }
    50 
    51 
    52     public function getUrl()
    53     {
    54         return $this->url;
    55     }
    56 
    57     public function setUrl($url)
    58     {
    59         $this->url = $url;
    60     }
    6139}
  • easycontent/trunk/app/forms/entities/ImportEntity.php

    r2189682 r2434037  
    44
    55use EasyContent\WordPress\Db\Models\WorkflowStage;
     6use EasyContent\WordPress\NoticesManager;
    67use EasyContent\WordPress\Pages\Import\Importer;
    78use EasyContent\WordPress\Plugin;
     
    5354                $newWorkflowStage = WorkflowStage::findByKey( $this->getNewStage() );
    5455            } catch ( \Exception $e ) {
    55                 Plugin::getInstance()->noticesManager->addNotice( 'Unable to find workflow stage', 'error' );
     56                Plugin::getInstance()->noticesManager->addNotice( 'Unable to find workflow stage', NoticesManager::TYPE_ERROR );
    5657                return false;
    5758            }
  • easycontent/trunk/app/forms/handlers/RefreshAllDataFormHandler.php

    r2285656 r2434037  
    99use EasyContent\WordPress\Db\Models\Category as CategoryDbModel;
    1010use EasyContent\WordPress\Db\Models\WorkflowStage as StageDbModel;
     11use EasyContent\WordPress\NoticesManager;
    1112use EasyContent\WordPress\Plugin;
    1213
     
    4243            StageDbModel::setDatabaseCache( $freshStages );
    4344        } catch ( \Exception $e ) {
    44             $nm->addNotice( $e->getMessage(), 'error' );
     45            $nm->addNotice( $e->getMessage(), NoticesManager::TYPE_ERROR );
    4546            return;
    4647        }
  • easycontent/trunk/easycontent-wp.php

    r2355111 r2434037  
    44 * Plugin URI:  https://easycontent.io
    55 * Description: Imports articles from EasyContent to your wordpress site and exports articles from your wordpress site to EasyContent
    6  * Version: 1.0.6
     6 * Version: 1.0.7
    77 * Requires at least: 5.0.7
    88 * Requires PHP: 5.6
     
    2121
    2222if ( ! defined( 'EASYCONTENT_PLUGIN_VERSION' ) ) {
    23     define( 'EASYCONTENT_PLUGIN_VERSION', '1.0.6' );
     23    define( 'EASYCONTENT_PLUGIN_VERSION', '1.0.7' );
    2424}
    2525
  • easycontent/trunk/readme.txt

    r2355111 r2434037  
    66Tested up to:       5.5
    77Requires PHP:       5.6
    8 Stable tag:         1.0.6
     8Stable tag:         1.0.7
    99License:            GPL-2.0+
    1010License URI:        http://www.gnu.org/licenses/gpl-2.0.html
     
    6161== Changelog ==
    6262
     63= 1.0.7 =
     64* Increased database code stability
     65* Added tool that will help to fix database schema if something went wrong
     66
    6367= 1.0.6 =
    6468* Added ability to push drafted post to EasyContent.io
  • easycontent/trunk/vendor/autoload.php

    r2355111 r2434037  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit54aed42cfa417ec4213926972db643ad::getLoader();
     7return ComposerAutoloaderInit2c67146a226c493fc98bf800e38cef4c::getLoader();
  • easycontent/trunk/vendor/composer/autoload_classmap.php

    r2285656 r2434037  
    279279    'EasyContent\\WordPress\\Metaboxes\\PostSyncMetaBox' => $baseDir . '/app/metaboxes/PostSyncMetaBox.php',
    280280    'EasyContent\\WordPress\\NoticesManager' => $baseDir . '/app/NoticesManager.php',
     281    'EasyContent\\WordPress\\Notices\\AdminNotice' => $baseDir . '/app/notices/AdminNotice.php',
     282    'EasyContent\\WordPress\\Notices\\AdminNoticeInterface' => $baseDir . '/app/notices/AdminNoticeInterface.php',
     283    'EasyContent\\WordPress\\Notices\\AdminNoticesService' => $baseDir . '/app/notices/AdminNoticesService.php',
    281284    'EasyContent\\WordPress\\Pages\\Import\\ArticlesListTable' => $baseDir . '/app/pages/import/ArticlesListTable.php',
    282285    'EasyContent\\WordPress\\Pages\\Import\\Importer' => $baseDir . '/app/pages/import/Importer.php',
  • easycontent/trunk/vendor/composer/autoload_real.php

    r2355111 r2434037  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit54aed42cfa417ec4213926972db643ad
     5class ComposerAutoloaderInit2c67146a226c493fc98bf800e38cef4c
    66{
    77    private static $loader;
     
    2323        }
    2424
    25         spl_autoload_register(array('ComposerAutoloaderInit54aed42cfa417ec4213926972db643ad', 'loadClassLoader'), true, true);
     25        spl_autoload_register(array('ComposerAutoloaderInit2c67146a226c493fc98bf800e38cef4c', 'loadClassLoader'), true, true);
    2626        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    27         spl_autoload_unregister(array('ComposerAutoloaderInit54aed42cfa417ec4213926972db643ad', 'loadClassLoader'));
     27        spl_autoload_unregister(array('ComposerAutoloaderInit2c67146a226c493fc98bf800e38cef4c', 'loadClassLoader'));
    2828
    2929        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3131            require_once __DIR__ . '/autoload_static.php';
    3232
    33             call_user_func(\Composer\Autoload\ComposerStaticInit54aed42cfa417ec4213926972db643ad::getInitializer($loader));
     33            call_user_func(\Composer\Autoload\ComposerStaticInit2c67146a226c493fc98bf800e38cef4c::getInitializer($loader));
    3434        } else {
    3535            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5252
    5353        if ($useStaticLoader) {
    54             $includeFiles = Composer\Autoload\ComposerStaticInit54aed42cfa417ec4213926972db643ad::$files;
     54            $includeFiles = Composer\Autoload\ComposerStaticInit2c67146a226c493fc98bf800e38cef4c::$files;
    5555        } else {
    5656            $includeFiles = require __DIR__ . '/autoload_files.php';
    5757        }
    5858        foreach ($includeFiles as $fileIdentifier => $file) {
    59             composerRequire54aed42cfa417ec4213926972db643ad($fileIdentifier, $file);
     59            composerRequire2c67146a226c493fc98bf800e38cef4c($fileIdentifier, $file);
    6060        }
    6161
     
    6464}
    6565
    66 function composerRequire54aed42cfa417ec4213926972db643ad($fileIdentifier, $file)
     66function composerRequire2c67146a226c493fc98bf800e38cef4c($fileIdentifier, $file)
    6767{
    6868    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • easycontent/trunk/vendor/composer/autoload_static.php

    r2355111 r2434037  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit54aed42cfa417ec4213926972db643ad
     7class ComposerStaticInit2c67146a226c493fc98bf800e38cef4c
    88{
    99    public static $files = array (
     
    502502        'EasyContent\\WordPress\\Metaboxes\\PostSyncMetaBox' => __DIR__ . '/../..' . '/app/metaboxes/PostSyncMetaBox.php',
    503503        'EasyContent\\WordPress\\NoticesManager' => __DIR__ . '/../..' . '/app/NoticesManager.php',
     504        'EasyContent\\WordPress\\Notices\\AdminNotice' => __DIR__ . '/../..' . '/app/notices/AdminNotice.php',
     505        'EasyContent\\WordPress\\Notices\\AdminNoticeInterface' => __DIR__ . '/../..' . '/app/notices/AdminNoticeInterface.php',
     506        'EasyContent\\WordPress\\Notices\\AdminNoticesService' => __DIR__ . '/../..' . '/app/notices/AdminNoticesService.php',
    504507        'EasyContent\\WordPress\\Pages\\Import\\ArticlesListTable' => __DIR__ . '/../..' . '/app/pages/import/ArticlesListTable.php',
    505508        'EasyContent\\WordPress\\Pages\\Import\\Importer' => __DIR__ . '/../..' . '/app/pages/import/Importer.php',
     
    16181621    {
    16191622        return \Closure::bind(function () use ($loader) {
    1620             $loader->prefixLengthsPsr4 = ComposerStaticInit54aed42cfa417ec4213926972db643ad::$prefixLengthsPsr4;
    1621             $loader->prefixDirsPsr4 = ComposerStaticInit54aed42cfa417ec4213926972db643ad::$prefixDirsPsr4;
    1622             $loader->classMap = ComposerStaticInit54aed42cfa417ec4213926972db643ad::$classMap;
     1623            $loader->prefixLengthsPsr4 = ComposerStaticInit2c67146a226c493fc98bf800e38cef4c::$prefixLengthsPsr4;
     1624            $loader->prefixDirsPsr4 = ComposerStaticInit2c67146a226c493fc98bf800e38cef4c::$prefixDirsPsr4;
     1625            $loader->classMap = ComposerStaticInit2c67146a226c493fc98bf800e38cef4c::$classMap;
    16231626
    16241627        }, null, ClassLoader::class);
  • easycontent/trunk/vendor/composer/installed.json

    r2285656 r2434037  
    10461046    {
    10471047        "name": "robmorgan/phinx",
    1048         "version": "0.11.4",
    1049         "version_normalized": "0.11.4.0",
     1048        "version": "0.11.7",
     1049        "version_normalized": "0.11.7.0",
    10501050        "source": {
    10511051            "type": "git",
    10521052            "url": "https://github.com/cakephp/phinx.git",
    1053             "reference": "10e8c3f6b09111f4c0ef128d5a43375e15286cc5"
    1054         },
    1055         "dist": {
    1056             "type": "zip",
    1057             "url": "https://api.github.com/repos/cakephp/phinx/zipball/10e8c3f6b09111f4c0ef128d5a43375e15286cc5",
    1058             "reference": "10e8c3f6b09111f4c0ef128d5a43375e15286cc5",
     1053            "reference": "3cdde73e0c33c410e076108b3e1603fabb5b330d"
     1054        },
     1055        "dist": {
     1056            "type": "zip",
     1057            "url": "https://api.github.com/repos/cakephp/phinx/zipball/3cdde73e0c33c410e076108b3e1603fabb5b330d",
     1058            "reference": "3cdde73e0c33c410e076108b3e1603fabb5b330d",
    10591059            "shasum": ""
    10601060        },
     
    10691069        "require-dev": {
    10701070            "cakephp/cakephp-codesniffer": "^3.0",
     1071            "ext-json": "*",
    10711072            "phpunit/phpunit": ">=5.7,<8.0",
    10721073            "sebastian/comparator": ">=1.2.3"
    10731074        },
    1074         "time": "2019-12-24T23:43:31+00:00",
     1075        "suggest": {
     1076            "ext-json": "Install if using JSON configuration format",
     1077            "symfony/yaml": "Install if using YAML configuration format"
     1078        },
     1079        "time": "2020-05-09T13:59:05+00:00",
    10751080        "bin": [
    10761081            "bin/phinx"
  • easycontent/trunk/vendor/robmorgan/phinx/README.md

    r2285656 r2434037  
    103103## Documentation
    104104
    105 Check out http://docs.phinx.org/en/latest/ for the comprehensive documentation.
     105Check out https://book.cakephp.org/phinx for the comprehensive documentation.
    106106
    107107Other translations include:
  • easycontent/trunk/vendor/robmorgan/phinx/UPGRADE_0.8.md

    r2189682 r2434037  
    1414  within a codebase and are merged in to master for deployment. It will no longer matter when the migrations
    1515  were created if it becomes necessary to rollback the migrations.
     16
     17* Using an older version of Phinx on a pre 5.6 MySQL installation could lead to a case of an invalid table definition
     18for the `default_migration_table` (e.g. `phinxlog`) when the database was upgraded to 5.6. On upgrading, if you used
     19phinx on a pre 5.6 MySQL installation, it is suggested to do the following:
     20
     21```
     22ALTER TABLE phinxlog MODIFY start_time timestamp NULL DEFAULT NULL;
     23ALTER TABLE phinxlog MODIFY end_time timestamp NULL DEFAULT NULL;
     24UPDATE phinxlog SET start_time = NULL WHERE start_time = '0000-00-00 00:00:00';
     25UPDATE phinxlog SET end_time = NULL WHERE end_time = '0000-00-00 00:00:00';
     26```
  • easycontent/trunk/vendor/robmorgan/phinx/composer.json

    r2285656 r2434037  
    3434    },
    3535    "require-dev": {
     36        "ext-json": "*",
    3637        "phpunit/phpunit": ">=5.7,<8.0",
    3738        "sebastian/comparator": ">=1.2.3",
     
    4849        }
    4950    },
     51    "suggest": {
     52        "ext-json": "Install if using JSON configuration format",
     53        "symfony/yaml": "Install if using YAML configuration format"
     54    },
    5055    "scripts": {
    5156        "check": [
  • easycontent/trunk/vendor/robmorgan/phinx/docs/en/commands.rst

    r2285656 r2434037  
    260260            ];
    261261
    262 Phinx auto-detects which language parser to use for files with ``*.yml``, ``*.json``, and ``*.php`` extensions. The appropriate
    263 parser may also be specified via the ``--parser`` and ``-p`` parameters. Anything other than  ``"json"`` or ``"php"`` is
    264 treated as YAML.
     262Phinx auto-detects which language parser to use for files with ``*.yaml``, ``*.yml``, ``*.json``, and ``*.php`` extensions.
     263The appropriate parser may also be specified via the ``--parser`` and ``-p`` parameters. Anything other than  ``"json"`` or
     264``"php"`` is treated as YAML.
    265265
    266266When using a PHP array, you can provide a ``connection`` key with an existing PDO instance. It is also important to pass
     
    331331    {
    332332
    333         $phinx = new PhinxApplication();       
     333        $phinx = new PhinxApplication();
    334334        $command = $phinx->find('migrate');
    335335
     
    339339            '--configuration' => '/path/to/config/phinx.yml'
    340340        ];
    341        
     341
    342342        $input = new ArrayInput($arguments);
    343343        $returnCode = $command->run(new ArrayInput($arguments), $output);
    344344        // ...
    345345    }
    346    
     346
    347347Here, you are instantianting the ``PhinxApplication``, telling it to find the ``migrate``
    348348command, defining the arguments to pass to it (which match the commandline arguments and flags),
  • easycontent/trunk/vendor/robmorgan/phinx/docs/en/configuration.rst

    r2285656 r2434037  
    88creates a default file in the root of your project directory. By default, this
    99file uses the YAML data serialization format, but you can use the ``--format``
    10 command line option to specify either ``yml``, ``json``, or ``php``.
     10command line option to specify either ``yaml``, ``yml``, ``json``, or ``php``.
    1111
    1212If a ``--configuration`` command line option is given, Phinx will load the
    13 specified file. Otherwise, it will attempt to find ``phinx.php``, ``phinx.json`` or
    14 ``phinx.yml`` and load the first file found. See the :doc:`Commands <commands>`
    15 chapter for more information.
     13specified file. Otherwise, it will attempt to find ``phinx.php``, ``phinx.json``,
     14``phinx.yml``, or ``phinx.yaml`` and load the first file found. See the
     15:doc:`Commands <commands>` chapter for more information.
    1616
    1717.. warning::
  • easycontent/trunk/vendor/robmorgan/phinx/docs/fr/configuration.rst

    r2285656 r2434037  
    1010
    1111If a ``--configuration`` command line option is given, Phinx will load the
    12 specified file. Otherwise, it will attempt to find ``phinx.php``, ``phinx.json`` or
    13 ``phinx.yml`` and load the first file found. See the :doc:`Commands <commands>`
    14 chapter for more information.
     12specified file. Otherwise, it will attempt to find ``phinx.php``, ``phinx.json``,
     13``phinx.yml`` or ``phinx.yaml`` and load the first file found. See the
     14:doc:`Commands <commands>` chapter for more information.
    1515
    1616.. warning::
  • easycontent/trunk/vendor/robmorgan/phinx/docs/ja/configuration.rst

    r2285656 r2434037  
    1010
    1111``--configuration`` コマンドラインオプションが与えられた場合、Phinx は指定されたファイルを
    12 ロードします。それ以外の場合は、 ``phinx.php`` 、 ``phinx.json`` または ``phinx.yml``
    13 を見つけて、最初に見つかったファイルを読み込みます。詳しくは、 :doc:`コマンド <commands>`
    14 の章をご覧下さい。
     12ロードします。それ以外の場合は、 ``phinx.php`` 、 ``phinx.json`` , ``phinx.yml``,
     13または ``phinx.yaml`` を見つけて、最初に見つかったファイルを読み込みます。詳しくは、
     14:doc:`コマンド <commands>` の章をご覧下さい。
    1515
    1616.. warning::
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Config/Config.php

    r2285656 r2434037  
    6464    public static function fromYaml($configFilePath)
    6565    {
     66        if (!class_exists('Symfony\\Component\\Yaml\\Yaml', true)) {
     67            throw new RuntimeException('Missing yaml parser, symfony/yaml package is not installed.');
     68        }
     69
    6670        $configFile = file_get_contents($configFilePath);
    6771        $configArray = Yaml::parse($configFile);
     
    8892    public static function fromJson($configFilePath)
    8993    {
     94        if (!function_exists('json_decode')) {
     95            throw new RuntimeException("Need to install JSON PHP extension to use JSON config");
     96        }
     97
    9098        $configArray = json_decode(file_get_contents($configFilePath), true);
    9199        if (!is_array($configArray)) {
     
    159167            }
    160168
    161             return $environments[$name];
     169            return $this->parseAgnosticDsn($environments[$name]);
    162170        }
    163171
     
    366374    {
    367375        // Get environment variables
    368         // $_ENV is empty because variables_order does not include it normally
     376        // Depending on configuration of server / OS and variables_order directive,
     377        // environment variables either end up in $_SERVER (most likely) or $_ENV,
     378        // so we search through both
    369379        $tokens = [];
    370         foreach ($_SERVER as $varname => $varvalue) {
     380        foreach (array_merge($_ENV, $_SERVER) as $varname => $varvalue) {
    371381            if (strpos($varname, 'PHINX_') === 0) {
    372382                $tokens['%%' . $varname . '%%'] = $varvalue;
     
    412422
    413423    /**
     424     * Parse a database-agnostic DSN into individual options.
     425     *
     426     * @param array $options Options
     427     *
     428     * @return array
     429     */
     430    protected function parseAgnosticDsn(array $options)
     431    {
     432        if (isset($options['dsn']) && is_string($options['dsn'])) {
     433            $regex = '#^(?P<adapter>[^\\:]+)\\://(?:(?P<user>[^\\:@]+)(?:\\:(?P<pass>[^@]*))?@)?'
     434                   . '(?P<host>[^\\:@/]+)(?:\\:(?P<port>[1-9]\\d*))?/(?P<name>[^\?]+)(?:\?(?P<query>.*))?$#';
     435            if (preg_match($regex, trim($options['dsn']), $parsedOptions)) {
     436                $additionalOpts = [];
     437                if (isset($parsedOptions['query'])) {
     438                    parse_str($parsedOptions['query'], $additionalOpts);
     439                }
     440                $validOptions = ['adapter', 'user', 'pass', 'host', 'port', 'name'];
     441                $parsedOptions = array_filter(array_intersect_key($parsedOptions, array_flip($validOptions)));
     442                $options = array_merge($additionalOpts, $parsedOptions, $options);
     443                unset($options['dsn']);
     444            }
     445        }
     446
     447        return $options;
     448    }
     449
     450    /**
    414451     * @inheritDoc
    415452     */
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Console/Command/AbstractCommand.php

    r2285656 r2434037  
    234234        }
    235235
    236         $possibleConfigFiles = ['phinx.php', 'phinx.json', 'phinx.yml'];
     236        $possibleConfigFiles = ['phinx.php', 'phinx.json', 'phinx.yaml', 'phinx.yml'];
    237237        foreach ($possibleConfigFiles as $configFile) {
    238238            try {
    239                 return $locator->locate($configFile, $cwd, $first = true);
     239                return $locator->locate($configFile, $cwd, true);
    240240            } catch (InvalidArgumentException $exception) {
    241241                $lastException = $exception;
     
    273273                    $parser = 'php';
    274274                    break;
     275                case 'yaml':
    275276                case 'yml':
    276277                default:
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Console/Command/Init.php

    r2285656 r2434037  
    5151    protected function execute(InputInterface $input, OutputInterface $output)
    5252    {
    53         $path = $this->resolvePath($input);
    5453        $format = strtolower($input->getOption('format'));
     54        $path = $this->resolvePath($input, $format);
    5555        $this->writeConfig($path, $format);
    5656
     
    6464     *
    6565     * @param \Symfony\Component\Console\Input\InputInterface $input Interface implemented by all input classes.
     66     * @param string $format Format to resolve for
    6667     *
    6768     * @throws \InvalidArgumentException
     
    6970     * @return string
    7071     */
    71     protected function resolvePath(InputInterface $input)
     72    protected function resolvePath(InputInterface $input, $format)
    7273    {
    7374        // get the migration path from the config
    7475        $path = (string)$input->getArgument('path');
    7576
    76         $format = strtolower($input->getOption('format'));
    77         if (!in_array($format, ['yml', 'json', 'php'])) {
     77        if (!in_array($format, ['yaml', 'yml', 'json', 'php'])) {
    7878            throw new InvalidArgumentException(sprintf(
    79                 'Invalid format "%s". Format must be either yml, json, or php.',
     79                'Invalid format "%s". Format must be either yaml, yml, json, or php.',
    8080                $format
    8181            ));
     
    135135        }
    136136
     137        if ($format === 'yaml') {
     138            $format = 'yml';
     139        }
     140
    137141        // load the config template
    138142        if (is_dir(__DIR__ . '/../../../data/Phinx')) {
    139143            $contents = file_get_contents(__DIR__ . '/../../../data/Phinx/' . self::FILE_NAME . '.' . $format . '.dist');
    140         } elseif ($format === 'yml') {
    141             $contents = file_get_contents(__DIR__ . '/../../../../' . self::FILE_NAME . '.' . $format);
     144        } elseif ($format === 'yml' || $format === 'yaml') {
     145            $contents = file_get_contents(__DIR__ . '/../../../../' . self::FILE_NAME . '.yml');
    142146        } else {
    143147            throw new RuntimeException(sprintf(
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php

    r2285656 r2434037  
    239239
    240240            array_unshift($columns, $column);
     241            if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) {
     242                throw new InvalidArgumentException('You cannot enable an auto incrementing ID field and a primary key');
     243            }
    241244            $options['primary_key'] = $options['id'];
    242245        }
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PdoAdapter.php

    r2285656 r2434037  
    371371        }
    372372
    373         $rows = $this->fetchAll(sprintf('SELECT * FROM %s ORDER BY %s', $this->getSchemaTableName(), $orderBy));
     373        // This will throw an exception if doing a --dry-run without any migrations as phinxlog
     374        // does not exist, so in that case, we can just expect to trivially return empty set
     375        try {
     376            $rows = $this->fetchAll(sprintf('SELECT * FROM %s ORDER BY %s', $this->quoteTableName($this->getSchemaTableName()), $orderBy));
     377        } catch (PDOException $e) {
     378            if (!$this->isDryRunEnabled()) {
     379                throw $e;
     380            }
     381            $rows = [];
     382        }
     383
    374384        foreach ($rows as $version) {
    375385            $result[$version['version']] = $version;
     
    425435            sprintf(
    426436                'UPDATE %1$s SET %2$s = CASE %2$s WHEN %3$s THEN %4$s ELSE %3$s END, %7$s = %7$s WHERE %5$s = \'%6$s\';',
    427                 $this->getSchemaTableName(),
     437                $this->quoteTableName($this->getSchemaTableName()),
    428438                $this->quoteColumnName('breakpoint'),
    429439                $this->castToBool(true),
     
    446456            sprintf(
    447457                'UPDATE %1$s SET %2$s = %3$s, %4$s = %4$s WHERE %2$s <> %3$s;',
    448                 $this->getSchemaTableName(),
     458                $this->quoteTableName($this->getSchemaTableName()),
    449459                $this->quoteColumnName('breakpoint'),
    450460                $this->castToBool(false),
     
    483493            sprintf(
    484494                'UPDATE %1$s SET %2$s = %3$s, %4$s = %4$s WHERE %5$s = \'%6$s\';',
    485                 $this->getSchemaTableName(),
     495                $this->quoteTableName($this->getSchemaTableName()),
    486496                $this->quoteColumnName('breakpoint'),
    487497                $this->castToBool($state),
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/PostgresAdapter.php

    r2285656 r2434037  
    208208
    209209            array_unshift($columns, $column);
     210            if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) {
     211                throw new InvalidArgumentException('You cannot enable an auto incrementing ID field and a primary key');
     212            }
    210213            $options['primary_key'] = $options['id'];
    211214        }
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Db/Adapter/SqlServerAdapter.php

    r2285656 r2434037  
    228228
    229229            array_unshift($columns, $column);
     230            if (isset($options['primary_key']) && (array)$options['id'] !== (array)$options['primary_key']) {
     231                throw new InvalidArgumentException('You cannot enable an auto incrementing ID field and a primary key');
     232            }
    230233            $options['primary_key'] = $options['id'];
    231234        }
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Migration/Manager/Environment.php

    r2285656 r2434037  
    191191    public function getOptions()
    192192    {
    193         return $this->parseAgnosticDsn($this->options);
    194     }
    195 
    196     /**
    197      * Parse a database-agnostic DSN into individual options.
    198      *
    199      * @param array $options Options
    200      *
    201      * @return array
    202      */
    203     protected function parseAgnosticDsn(array $options)
    204     {
    205         if (isset($options['dsn']) && is_string($options['dsn'])) {
    206             $regex = '#^(?P<adapter>[^\\:]+)\\://(?:(?P<user>[^\\:@]+)(?:\\:(?P<pass>[^@]*))?@)?'
    207                    . '(?P<host>[^\\:@/]+)(?:\\:(?P<port>[1-9]\\d*))?/(?P<name>[^\?]+)(?:\?(?P<query>.*))?$#';
    208             if (preg_match($regex, trim($options['dsn']), $parsedOptions)) {
    209                 $additionalOpts = [];
    210                 if (isset($parsedOptions['query'])) {
    211                     parse_str($parsedOptions['query'], $additionalOpts);
    212                 }
    213                 $validOptions = ['adapter', 'user', 'pass', 'host', 'port', 'name'];
    214                 $parsedOptions = array_filter(array_intersect_key($parsedOptions, array_flip($validOptions)));
    215                 $options = array_merge($additionalOpts, $parsedOptions, $options);
    216                 unset($options['dsn']);
    217             }
    218         }
    219 
    220         return $options;
     193        return $this->options;
    221194    }
    222195
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Migration/Migration.template.php.dist

    r2189682 r2434037  
    1111     *
    1212     * More information on writing migrations is available here:
    13      * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     13     * https://book.cakephp.org/phinx/0/en/migrations.html
    1414     *
    1515     * The following commands can be used in this method and Phinx will
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Migration/MigrationInterface.php

    r2285656 r2434037  
    141141     * Executes a SQL statement and returns the result as an array.
    142142     *
    143      * @param string $sql SQL
    144      *
    145      * @return array
     143     * To improve IDE auto-completion possibility, you can overwrite the query method
     144     * phpDoc in your (typically custom abstract parent) migration class, where you can set
     145     * the return type by the adapter in your current use.
     146     *
     147     * @param string $sql SQL
     148     *
     149     * @return mixed
    146150     */
    147151    public function query($sql);
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Seed/Seed.template.php.dist

    r2189682 r2434037  
    1212     *
    1313     * More information on writing seeders is available here:
    14      * http://docs.phinx.org/en/latest/seeding.html
     14     * https://book.cakephp.org/phinx/0/en/seeding.html
    1515     */
    1616    public function run()
  • easycontent/trunk/vendor/robmorgan/phinx/src/Phinx/Wrapper/TextWrapper.php

    r2285656 r2434037  
    8484            $command += ['-p' => $this->getOption('parser')];
    8585        }
     86        if ($this->hasOption('format')) {
     87            $command += ['-f' => $this->getOption('format')];
     88        }
    8689
    8790        return $this->executeRun($command);
     
    169172        if (isset($target)) {
    170173            // Need to use isset() with rollback, because -t0 is a valid option!
    171             // See http://docs.phinx.org/en/latest/commands.html#the-rollback-command
     174            // See https://book.cakephp.org/phinx/0/en/commands.html#the-rollback-command
    172175            $command += ['-t' => $target];
    173176        }
  • easycontent/trunk/views/admin/pages/connection.php

    r2327436 r2434037  
    5757                </tr>
    5858                <tr>
    59                     <th scope="row">
    60                         <label for="msar-url-input">
    61                             <?= esc_html__( 'Current site URL', EASYCONTENT_TXTDOMAIN ) ?>
    62                         </label>
    63                     </th>
    64                     <td>
    65                         <?php if ( $referer ) : ?>
    66                             <span id="msar-url-wrapper">
    67                                 <?= esc_html( $referer ) ?>
    68                                 <a href="#" id="msar-change-url-button">
    69                                     <?= esc_html__( 'Change', EASYCONTENT_TXTDOMAIN ) ?>
    70                                 </a>
    71                             </span>
    72                         <?php endif ?>
    73 
    74                         <input
    75                             id="msar-url-input"
    76                             class="regular-text"
    77                             name="<?= esc_attr( $formView['url']->vars['full_name'] ) ?>"
    78                             type="<?= esc_attr( $referer ? 'hidden' : 'text' ) ?>"
    79                             value="<?= esc_attr( $referer ?: '' ) ?>"
    80                             placeholder="<?= esc_attr__( 'Please enter current site URL', EASYCONTENT_TXTDOMAIN ) ?>">
    81 
    82                         <?php if ( ! $formView['url']->vars['valid'] ) : ?>
    83                             <?php foreach ( $formView['url']->vars['errors'] as $error ) :
    84                                 /** @var Symfony\Component\Form\FormError $error */ ?>
    85                                 <p style="color: red;"><?= esc_html( $error->getMessage() ) ?></p>
    86                             <?php endforeach ?>
    87                         <?php endif ?>
    88 
     59                    <th scope="row" style="padding-top: 0; padding-bottom: 0;">&nbsp;</th>
     60                    <td style="padding-top: 0; padding-bottom: 0;">
    8961                        <p class="description" id="tagline-ec-private-api-key">
    90                             <a href="https://easycontent.io/help-article/wordpress-integration">
     62                            <a href="https://easycontent.io/help-article/wordpress-integration" target="_blank">
    9163                                <?= esc_html__( 'How to get your API key?', EASYCONTENT_TXTDOMAIN ) ?>
    9264                            </a>
     
    10779    </form>
    10880</div>
    109 
    110 <script type="application/javascript">
    111     (function($) {
    112         $(document).ready(function() {
    113             $('#msar-change-url-button').click(function(e) {
    114                 e.preventDefault();
    115 
    116                 $('#msar-url-wrapper').hide();
    117                 $('#msar-url-input').attr('type', 'text');
    118             });
    119         });
    120     })(jQuery);
    121 </script>
Note: See TracChangeset for help on using the changeset viewer.