Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
870db3f9
Commit
870db3f9
authored
12 years ago
by
Chris Leppanen
Browse files
Options
Downloads
Patches
Plain Diff
Some crap snuck into that last commit.
parent
7c462d05
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
feeds.module
+25
-30
25 additions, 30 deletions
feeds.module
includes/FeedsImporter.inc
+10
-9
10 additions, 9 deletions
includes/FeedsImporter.inc
with
35 additions
and
39 deletions
feeds.module
+
25
−
30
View file @
870db3f9
...
...
@@ -43,13 +43,14 @@ function feeds_hook_info() {
function
feeds_cron
()
{
if
(
$importers
=
feeds_reschedule
())
{
foreach
(
$importers
as
$id
)
{
feeds_importer
(
$id
)
->
schedule
();
$rows
=
db_query
(
"SELECT feed_nid FROM
{
feeds_source
}
WHERE id = :id"
,
array
(
':id'
=>
$id
));
foreach
(
$rows
as
$row
)
{
feeds_source
(
$id
,
$row
->
feed_nid
)
->
schedule
();
}
}
feeds_reschedule
(
FALSE
);
}
// Expire old log entries.
db_delete
(
'feeds_log'
)
->
condition
(
'request_time'
,
REQUEST_TIME
-
604800
,
'<'
)
...
...
@@ -189,37 +190,31 @@ function feeds_batch($method, $importer_id, $feed_nid = 0, &$context) {
}
}
/**
* Reschedules an importer's sources.
*
* The importers designated to be rescheduled wil have their sources
* rescheduled on the next cron run.
*
* @param string $importer_id
* (Optional) If an importer id, that importer will be added to the list
* for rescheduling. If NULL, the list of importers will be reset.
*
* @return array
* The list of importers that need to have their sources rescheduled.
*
* @see feeds_cron()
*/
function
feeds_reschedule
(
$importer_id
=
NULL
)
{
// Get a list of importers.
$reschedule
=
variable_get
(
'feeds_reschedule'
,
array
());
// We are adding one to the list.
if
(
$importer_id
)
{
$reschedule
[]
=
$importer_id
;
$reschedule
=
array_unique
(
$reschedule
);
variable_set
(
'feeds_reschedule'
,
$reschedule
);
/**
* Reschedule one or all importers.
*
* @param $importer_id
* If TRUE, all importers will be rescheduled, if FALSE, no importers will
* be rescheduled, if an importer id, only importer of that id will be
* rescheduled.
*
* @return
* TRUE if all importers need rescheduling. FALSE if no rescheduling is
* required. An array of importers that need rescheduling.
*/
function
feeds_reschedule
(
$importer_id
=
NULL
)
{
$reschedule
=
variable_get
(
'feeds_reschedule'
,
FALSE
);
if
(
$importer_id
===
TRUE
||
$importer_id
===
FALSE
)
{
$reschedule
=
$importer_id
;
}
else
{
variable_del
(
'feeds_reschedule'
);
elseif
(
is_string
(
$importer_id
)
&&
$reschedule
!==
TRUE
)
{
$reschedule
=
is_array
(
$reschedule
)
?
$reschedule
:
array
();
$reschedule
[
$importer_id
]
=
$importer_id
;
}
variable_set
(
'feeds_reschedule'
,
$reschedule
);
if
(
$reschedule
===
TRUE
)
{
return
feeds_enabled_importers
();
}
return
$reschedule
;
}
...
...
This diff is collapsed.
Click to expand it.
includes/FeedsImporter.inc
+
10
−
9
View file @
870db3f9
...
...
@@ -95,7 +95,6 @@ class FeedsImporter extends FeedsConfigurable {
else
{
JobScheduler
::
get
(
'feeds_importer_expire'
)
->
remove
(
$job
);
}
debug
(
$job
);
}
/**
...
...
@@ -127,20 +126,13 @@ class FeedsImporter extends FeedsConfigurable {
if
(
$config
=
db_query
(
"SELECT config FROM
{
feeds_importer
}
WHERE id = :id"
,
array
(
':id'
=>
$this
->
id
))
->
fetchField
())
{
drupal_write_record
(
'feeds_importer'
,
$save
,
'id'
);
// Only rebuild menu if content_type has changed. Don't worry about
// rebuilding menus when creating a new importer since it will default
// to the standalone page.
$config
=
unserialize
(
$config
);
if
(
$config
[
'content_type'
]
!=
$save
->
config
[
'content_type'
])
{
variable_set
(
'menu_rebuild_needed'
,
TRUE
);
}
// Reschedule this importer's sources if the import period changed.
if
(
$config
[
'import_period'
]
!=
$save
->
config
[
'import_period'
])
{
feeds_reschedule
(
$this
->
id
);
}
}
else
{
drupal_write_record
(
'feeds_importer'
,
$save
);
...
...
@@ -176,7 +168,6 @@ class FeedsImporter extends FeedsConfigurable {
);
if
(
$this
->
export_type
&
EXPORT_IN_CODE
)
{
feeds_reschedule
(
$this
->
id
);
$this
->
schedule
();
}
else
{
JobScheduler
::
get
(
'feeds_importer_expire'
)
->
remove
(
$job
);
...
...
@@ -319,6 +310,16 @@ class FeedsImporter extends FeedsConfigurable {
);
return
$form
;
}
/**
* Reschedule if import period changes.
*/
public
function
configFormSubmit
(
&
$values
)
{
if
(
$this
->
config
[
'import_period'
]
!=
$values
[
'import_period'
])
{
feeds_reschedule
(
$this
->
id
);
}
parent
::
configFormSubmit
(
$values
);
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment