mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-29 20:41:03 +00:00
CS
This commit is contained in:
parent
f40c88eb1f
commit
3ef055ced3
27 changed files with 37 additions and 37 deletions
|
@ -28,7 +28,7 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
|
||||||
*/
|
*/
|
||||||
public function up(Schema $schema)
|
public function up(Schema $schema)
|
||||||
{
|
{
|
||||||
$this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
|
$this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
|
||||||
|
|
||||||
// remove all FK from entry_tag
|
// remove all FK from entry_tag
|
||||||
switch ($this->connection->getDatabasePlatform()->getName()) {
|
switch ($this->connection->getDatabasePlatform()->getName()) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
|
||||||
*/
|
*/
|
||||||
public function up(Schema $schema)
|
public function up(Schema $schema)
|
||||||
{
|
{
|
||||||
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
|
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
|
||||||
|
|
||||||
$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
|
$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
|
||||||
*/
|
*/
|
||||||
public function down(Schema $schema)
|
public function down(Schema $schema)
|
||||||
{
|
{
|
||||||
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
|
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
|
||||||
|
|
||||||
$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
|
$this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
|
||||||
|
|
||||||
$clientsTable->dropColumn('user_id', 'integer');
|
$clientsTable->dropColumn('user_id', 'integer');
|
||||||
|
|
||||||
if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
|
if ('sqlite' !== $this->connection->getDatabasePlatform()->getName()) {
|
||||||
$clientsTable->removeForeignKey($this->constraintName);
|
$clientsTable->removeForeignKey($this->constraintName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Version20170510082609 extends AbstractMigration implements ContainerAwareI
|
||||||
*/
|
*/
|
||||||
public function up(Schema $schema)
|
public function up(Schema $schema)
|
||||||
{
|
{
|
||||||
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
|
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
|
||||||
|
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
|
||||||
|
@ -46,7 +46,7 @@ class Version20170510082609 extends AbstractMigration implements ContainerAwareI
|
||||||
*/
|
*/
|
||||||
public function down(Schema $schema)
|
public function down(Schema $schema)
|
||||||
{
|
{
|
||||||
$this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
|
$this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL');
|
||||||
|
|
||||||
foreach ($this->fields as $field) {
|
foreach ($this->fields as $field) {
|
||||||
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
|
$this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Version20170719231144 extends AbstractMigration implements ContainerAwareI
|
||||||
*/
|
*/
|
||||||
public function up(Schema $schema)
|
public function up(Schema $schema)
|
||||||
{
|
{
|
||||||
$this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
|
$this->skipIf('sqlite' === $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
|
||||||
|
|
||||||
// Find tags which need to be merged
|
// Find tags which need to be merged
|
||||||
$dupTags = $this->connection->query('
|
$dupTags = $this->connection->query('
|
||||||
|
|
|
@ -145,7 +145,7 @@ class TagRestController extends WallabagRestController
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (count($tag->getEntries()) === 0) {
|
if (0 === count($tag->getEntries())) {
|
||||||
$em->remove($tag);
|
$em->remove($tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ListUserCommand extends ContainerAwareCommand
|
||||||
'%s/%s%s user(s) displayed.',
|
'%s/%s%s user(s) displayed.',
|
||||||
count($users),
|
count($users),
|
||||||
$nbUsers,
|
$nbUsers,
|
||||||
$input->getArgument('search') === null ? '' : ' (filtered)'
|
null === $input->getArgument('search') ? '' : ' (filtered)'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class ShowUserCommand extends ContainerAwareCommand
|
||||||
sprintf('Email: %s', $user->getEmail()),
|
sprintf('Email: %s', $user->getEmail()),
|
||||||
sprintf('Display name: %s', $user->getName()),
|
sprintf('Display name: %s', $user->getName()),
|
||||||
sprintf('Creation date: %s', $user->getCreatedAt()->format('Y-m-d H:i:s')),
|
sprintf('Creation date: %s', $user->getCreatedAt()->format('Y-m-d H:i:s')),
|
||||||
sprintf('Last login: %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'),
|
sprintf('Last login: %s', null !== $user->getLastLogin() ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'),
|
||||||
sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'),
|
sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,7 +348,7 @@ class ConfigController extends Controller
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (count($tag->getEntries()) === 0) {
|
if (0 === count($tag->getEntries())) {
|
||||||
$em->remove($tag);
|
$em->remove($tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ class EntryController extends Controller
|
||||||
public function showUnreadAction(Request $request, $page)
|
public function showUnreadAction(Request $request, $page)
|
||||||
{
|
{
|
||||||
// load the quickstart if no entry in database
|
// load the quickstart if no entry in database
|
||||||
if ((int) $page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
|
if (1 === (int) $page && 0 === $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId())) {
|
||||||
return $this->redirect($this->generateUrl('quickstart'));
|
return $this->redirect($this->generateUrl('quickstart'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class ExportController extends Controller
|
||||||
$methodBuilder = 'getBuilderFor' . $method . 'ByUser';
|
$methodBuilder = 'getBuilderFor' . $method . 'ByUser';
|
||||||
$repository = $this->get('wallabag_core.entry_repository');
|
$repository = $this->get('wallabag_core.entry_repository');
|
||||||
|
|
||||||
if ($category === 'tag_entries') {
|
if ('tag_entries' === $category) {
|
||||||
$tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
|
$tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
|
||||||
|
|
||||||
$entries = $repository->findAllByTagId(
|
$entries = $repository->findAllByTagId(
|
||||||
|
|
|
@ -65,7 +65,7 @@ class TagController extends Controller
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// remove orphan tag in case no entries are associated to it
|
// remove orphan tag in case no entries are associated to it
|
||||||
if (count($tag->getEntries()) === 0) {
|
if (0 === count($tag->getEntries())) {
|
||||||
$em->remove($tag);
|
$em->remove($tag);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TablePrefixSubscriber implements EventSubscriber
|
||||||
$classMetadata->setPrimaryTable(['name' => $this->prefix . $classMetadata->getTableName()]);
|
$classMetadata->setPrimaryTable(['name' => $this->prefix . $classMetadata->getTableName()]);
|
||||||
|
|
||||||
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
|
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
|
||||||
if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
|
if (ClassMetadataInfo::MANY_TO_MANY === $mapping['type'] && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
|
||||||
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
|
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
|
||||||
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
|
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class StringToListTransformer implements DataTransformerInterface
|
||||||
*/
|
*/
|
||||||
public function reverseTransform($string)
|
public function reverseTransform($string)
|
||||||
{
|
{
|
||||||
if ($string === null) {
|
if (null === $string) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
|
||||||
{
|
{
|
||||||
// required by credentials below
|
// required by credentials below
|
||||||
$host = strtolower($host);
|
$host = strtolower($host);
|
||||||
if (substr($host, 0, 4) === 'www.') {
|
if ('www.' === substr($host, 0, 4)) {
|
||||||
$host = substr($host, 4);
|
$host = substr($host, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
|
||||||
|
|
||||||
$extraFields = [];
|
$extraFields = [];
|
||||||
foreach ($extraFieldsStrings as $extraField) {
|
foreach ($extraFieldsStrings as $extraField) {
|
||||||
if (strpos($extraField, '=') === false) {
|
if (false === strpos($extraField, '=')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ class ContentProxy
|
||||||
$date = $value;
|
$date = $value;
|
||||||
|
|
||||||
// is it a timestamp?
|
// is it a timestamp?
|
||||||
if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
|
if (false !== filter_var($date, FILTER_VALIDATE_INT)) {
|
||||||
$date = '@' . $date;
|
$date = '@' . $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Matches
|
||||||
{
|
{
|
||||||
public function __invoke($subject, $pattern)
|
public function __invoke($subject, $pattern)
|
||||||
{
|
{
|
||||||
if ($pattern[0] === "'") {
|
if ("'" === $pattern[0]) {
|
||||||
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
|
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class NotMatches
|
||||||
{
|
{
|
||||||
public function __invoke($subject, $pattern)
|
public function __invoke($subject, $pattern)
|
||||||
{
|
{
|
||||||
if ($pattern[0] === "'") {
|
if ("'" === $pattern[0]) {
|
||||||
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
|
$pattern = sprintf("'%%%s%%'", substr($pattern, 1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,6 @@ class Matches
|
||||||
{
|
{
|
||||||
public function __invoke($subject, $pattern)
|
public function __invoke($subject, $pattern)
|
||||||
{
|
{
|
||||||
return stripos($subject, $pattern) !== false;
|
return false !== stripos($subject, $pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,6 @@ class NotMatches
|
||||||
{
|
{
|
||||||
public function __invoke($subject, $pattern)
|
public function __invoke($subject, $pattern)
|
||||||
{
|
{
|
||||||
return stripos($subject, $pattern) === false;
|
return false === stripos($subject, $pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ abstract class AbstractImport implements ImportInterface
|
||||||
$entryToBeFlushed[] = $entry;
|
$entryToBeFlushed[] = $entry;
|
||||||
|
|
||||||
// flush every 20 entries
|
// flush every 20 entries
|
||||||
if (($i % 20) === 0) {
|
if (0 === ($i % 20)) {
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
foreach ($entryToBeFlushed as $entry) {
|
foreach ($entryToBeFlushed as $entry) {
|
||||||
|
|
|
@ -171,7 +171,7 @@ abstract class BrowserImport extends AbstractImport
|
||||||
$entryToBeFlushed[] = $entry;
|
$entryToBeFlushed[] = $entry;
|
||||||
|
|
||||||
// flush every 20 entries
|
// flush every 20 entries
|
||||||
if (($i % 20) === 0) {
|
if (0 === ($i % 20)) {
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
foreach ($entryToBeFlushed as $entry) {
|
foreach ($entryToBeFlushed as $entry) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ChromeImport extends BrowserImport
|
||||||
'created_at' => substr($entry['date_added'], 0, 10),
|
'created_at' => substr($entry['date_added'], 0, 10),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
|
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||||
$data['tags'] = $entry['tags'];
|
$data['tags'] = $entry['tags'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class FirefoxImport extends BrowserImport
|
||||||
'created_at' => substr($entry['dateAdded'], 0, 10),
|
'created_at' => substr($entry['dateAdded'], 0, 10),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
|
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||||
$data['tags'] = $entry['tags'];
|
$data['tags'] = $entry['tags'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class InstapaperImport extends AbstractImport
|
||||||
|
|
||||||
$entries = [];
|
$entries = [];
|
||||||
$handle = fopen($this->filepath, 'r');
|
$handle = fopen($this->filepath, 'r');
|
||||||
while (($data = fgetcsv($handle, 10240)) !== false) {
|
while (false !== ($data = fgetcsv($handle, 10240))) {
|
||||||
if ('URL' === $data[0]) {
|
if ('URL' === $data[0]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,8 @@ class InstapaperImport extends AbstractImport
|
||||||
'url' => $data[0],
|
'url' => $data[0],
|
||||||
'title' => $data[1],
|
'title' => $data[1],
|
||||||
'status' => $data[3],
|
'status' => $data[3],
|
||||||
'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred',
|
'is_archived' => 'Archive' === $data[3] || 'Starred' === $data[3],
|
||||||
'is_starred' => $data[3] === 'Starred',
|
'is_starred' => 'Starred' === $data[3],
|
||||||
'html' => false,
|
'html' => false,
|
||||||
'tags' => $tags,
|
'tags' => $tags,
|
||||||
];
|
];
|
||||||
|
|
|
@ -149,7 +149,7 @@ class PocketImport extends AbstractImport
|
||||||
// - first call get 5k offset 0
|
// - first call get 5k offset 0
|
||||||
// - second call get 5k offset 5k
|
// - second call get 5k offset 5k
|
||||||
// - and so on
|
// - and so on
|
||||||
if (count($entries['list']) === self::NB_ELEMENTS) {
|
if (self::NB_ELEMENTS === count($entries['list'])) {
|
||||||
++$run;
|
++$run;
|
||||||
|
|
||||||
return $this->import(self::NB_ELEMENTS * $run);
|
return $this->import(self::NB_ELEMENTS * $run);
|
||||||
|
@ -175,7 +175,7 @@ class PocketImport extends AbstractImport
|
||||||
*/
|
*/
|
||||||
public function parseEntry(array $importedEntry)
|
public function parseEntry(array $importedEntry)
|
||||||
{
|
{
|
||||||
$url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] !== '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
|
$url = isset($importedEntry['resolved_url']) && '' !== $importedEntry['resolved_url'] ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
|
||||||
|
|
||||||
$existingEntry = $this->em
|
$existingEntry = $this->em
|
||||||
->getRepository('WallabagCoreBundle:Entry')
|
->getRepository('WallabagCoreBundle:Entry')
|
||||||
|
@ -194,15 +194,15 @@ class PocketImport extends AbstractImport
|
||||||
$this->fetchContent($entry, $url);
|
$this->fetchContent($entry, $url);
|
||||||
|
|
||||||
// 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
|
// 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
|
||||||
$entry->setArchived($importedEntry['status'] === 1 || $this->markAsRead);
|
$entry->setArchived(1 === $importedEntry['status'] || $this->markAsRead);
|
||||||
|
|
||||||
// 0 or 1 - 1 If the item is starred
|
// 0 or 1 - 1 If the item is starred
|
||||||
$entry->setStarred($importedEntry['favorite'] === 1);
|
$entry->setStarred(1 === $importedEntry['favorite']);
|
||||||
|
|
||||||
$title = 'Untitled';
|
$title = 'Untitled';
|
||||||
if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] !== '') {
|
if (isset($importedEntry['resolved_title']) && '' !== $importedEntry['resolved_title']) {
|
||||||
$title = $importedEntry['resolved_title'];
|
$title = $importedEntry['resolved_title'];
|
||||||
} elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] !== '') {
|
} elseif (isset($importedEntry['given_title']) && '' !== $importedEntry['given_title']) {
|
||||||
$title = $importedEntry['given_title'];
|
$title = $importedEntry['given_title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class WallabagV1Import extends WallabagImport
|
||||||
$data['html'] = $this->fetchingErrorMessage;
|
$data['html'] = $this->fetchingErrorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
|
if (array_key_exists('tags', $entry) && '' !== $entry['tags']) {
|
||||||
$data['tags'] = $entry['tags'];
|
$data['tags'] = $entry['tags'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue