Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong context for 'continue' #42

Closed
wants to merge 5 commits into from

Conversation

okonomiyaki3000
Copy link
Contributor

In the rare case that a content plugin returns false from the onContentBeforeSave event when creating a new folder in the media manager, we should return false rather than 'continue' which can only be used inside loops anyway.

@infograf768
Copy link
Member

Please add in tracker with patch.

@okonomiyaki3000
Copy link
Contributor Author

Do you mean the tracker on joomlacode.org? I've tried to use it before but I can't stay logged in. Practically every page load loses my session. It's super annoying.

@okonomiyaki3000
Copy link
Contributor Author

OK, well, I guess this bug will go unreported and unfixed because your tracker site doesn't work properly. Do you have a tracker for your tracker? Maybe I can report a bug there.

@elkuku
Copy link
Contributor

elkuku commented Dec 20, 2011

Ah come on, please don't give up so quickly :)
The CMS is in a state of "transition". The tracker on joomlacode.org is somewhat "old" and is going to be replaced soon - At least that is what they are saying... We are all waiting eagerly to fill this space here with pull requests because it seems that there are a lot of people getting very comfort with git and GitHub.
BTW: The code enhancements you are proposing for CodeMirror are looking quite good :) I would recommend though not to mix "topics". This allows for easier testing and further merging of your code.

Keep going, pls ;)

@okonomiyaki3000
Copy link
Contributor Author

It's no problem. I can wait until joomlacode.org gets updated if that's what's required. I have several other enhancements to various parts of the system as well. I'm a big fan of Joomla and I hope to help make it even better.

@okonomiyaki3000
Copy link
Contributor Author

So, is this tracker issue getting fixed? Is anyone else even having the same trouble?

Buddhima pushed a commit to Buddhima/joomla-cms that referenced this pull request Jul 8, 2013
GSOC Project: com_services or front end website administration
wilsonge referenced this pull request in wilsonge/joomla-cms Jun 12, 2014
[imp] Move extensionupdater markup to JLayouts
beat added a commit to beat/joomla-cms that referenced this pull request Dec 16, 2015
… (....) usages

Instead of using:

`" AND columnname IN " . implode( $array )`

and have escaping outside the query (and hard to security-review), I suggest:

`" AND columname IN (" . $db->safeArrayOfIntegersToCSV($array) . ")"`

Which makes security-reviews much easier (and automatable). This function and its generalized use would have avoided vulnerability in joomla#42 joomla/cms-security#42 (comment)
wilsonge added a commit that referenced this pull request Apr 7, 2016
wilsonge pushed a commit that referenced this pull request Jan 23, 2017
* simple is better

* one more
wilsonge pushed a commit that referenced this pull request May 31, 2017
* codestyle

* code style

* codestyle

* codestyle

* codestyle

* thanks @wojsmol

* corrections - thanks @Quy

* corrections - thanks @Quy

* oops

* make @Quy happy

* Update article.xml

* Remove space

* Update config.xml (#14)

* Update filter.xml (#15)

* Update config.xml (#16)

* Update profile.xml (#17)

* Update application.xml (#18)

* Update article.xml (#19)

* Update filter_articles.xml (#20)

* Update config.xml (#24)

* Update config.xml (#23)

* Update filter_fields.xml (#22)

* Update filter_featured.xml (#21)

* Update override.xml (#25)

* Update config.xml

* Update config.xml (#26)

* Update itemadmin_alias.xml (#30)

* Update itemadmin.xml (#29)

* Update item.xml (#27)

* Update item_alias.xml (#28)

* Update itemadmin_url.xml (#31)

* Update module.xml (#32)

* Update plugin.xml (#33)

* Update config.xml (#34)

* Update link.xml (#35)

* Update config.xml (#36)

* Update style.xml (#38)

* Update config.xml (#37)

* Update note.xml (#42)

* Update group.xml (#41)

* Update filter_debuggroup.xml (#40)

* Update config.xml (#39)

* corrections for @andrepereiradasilva

* gotya
ditsuke added a commit to ditsuke/joomla-cms that referenced this pull request Nov 15, 2021
bembelimen added a commit that referenced this pull request Nov 26, 2021
* Fix task filter ordering

Order now matches the order of columns the db table.

Ref: #35143#discussion_r700213211 / @brianteeman.

* Improve com_scheduler language strings

Improves a task form hint, a label.

Refs: #35143#discussion_r700203125
      #35143#discussion_r700202862
      @brianteeman.

* Scheduler runner as a shutdown_function

The schedule runner trigger is now bound as a shutdown_function.
The function is registered by a onBeforeRender listener.

* Enhance task locks and events

- Updates task locks (the `locked` column) so they now use a timestamp
  to allow for recovery from a fatal failure. Includes updates to SQL
  scripts.
- Dispatch a new onTaskRecoverFailure event on "recovery" from a fatal
  failure.
- Actually dispatch task exit events (oops!)
- Update the event class declaration for onExecuteTask to be more
  elegant, readable. [1]

[1]: http://#35143#discussion_r700897628 / @Denitz

* Add a sanity check to TaskPluginTrait

Adds a pre-broadcast sanity check for plugins with invalid an TASK_MAP.
The advertiseRoutines method will no longer try to advertise tasks that
don't have a corresponding 'langConstPrefix'.

* Fix fatal task failure check

Fixes the failure check (the lock should not be null) and
enhances a comment + styling.

* Increase scheduler plugin hook priority

Increases the priority for the registerRunner hook to PHP_INT_MAX,
although I'm not yet sure if onBeforeRender is the first event to be
fired (probably not).

* Fix event dispatchers in the Task class

The onTaskRecoverFailure and exit task weren't passing the
event name to dispatchers. Oops!
P.S. I don't know why that's required with the new Event classes.

* Cleanup com_scheduler manifest

Removes menu link (was supposed to go before).

* Add filtering by lock state in TasksModel

Adds support for filtering by the "lock" state of a task. Also in
the process defines different lock levels: hard locks and soft locks.
I think in the future, the filtering states should maybe
go into a namespace/class for constants.

* Add task timeout config to "com_scheduler"

Adds a configuration field for a global task timeout.
The timeout serves the purpose of safely declaring a hard-limit on how
long tasks can be considered as running once a lock on them is acquired.
Right now the default is 300s (5min) but this can be re-evaluated
in the future to a more sensible value if needed.

* Update language file for "com_scheduler"

Adds new constants for the component configuration form.

* Bugfix and update Scheduler API class

- Now fetches all fields from the DB (this broke things as the `locked`
  field was never fetched!!)
- Adds locked state filtering as a default (excludes hard-locked jobs).

* Add priority column to `#__scheduler_tasks`

- Adds a priority column to the tasks table, also a linked index.
- Fixes update SQL script styling.

* Add task priority to Task form and filter form

* Add priority, multi-ordering support to TasksModel

- Adds priority to the filter_fields config.
- Adds support for a `list.multi_ordering` model state variable which
  can be used to sort by multiple fields (limitation for the standard
  `list.ordering` `list.direction` model). The way this is right now
  means we pass unquoted names to the db which should be fixed in the
  future. In any case this is not exposed in the filter form but only
  meant to be used by internal handlers interacting with the model.
- Fixes behaviour for high collision ordering fields (used to order
  first by title and then by the targeted column).

* Update task timeout with config fetch

The Task driver class now fetches the task timeout from the component
config.

* Add priority-aware task queue to Scheduler class

The fetchTasks() method now uses multi-ordering with priority as the
primary ordering column to make the task queue priority aware.

* Update language files for com_scheduler

- Adds language constants for the task priority config in the task and
  tasks filter form.
- Sneaks in a description attribute for the priority form field.

* Bugfix and add an 'Advanced' tab to the task form

- Moves the log config and task priority to the advanced tab.
- Fixes a bug with using `joomla.edit.params`, which is now used
  for rendering all injected task routine parameters.

* Enhance orphan task handling in Task driver

- Dispatches now an event if task to run is orphaned, then skip the
  execution and exit early with a new exit code.
- Adds a skipExecution method to the Task class.
- Enhanced the handleExit method through an events map to dispatch
  other events based on exit code.
- Adds a new code for orphaned tasks to the Status namespace class.

* Enhance orphan handling in Scheduler, update lang

- Scheduler now includes orphaned tasks by default. Before this,
  the ::runTask() method never got to handling or logging orphaned
  tasks because of the default filtering excluding them.
- Adds exceptional log for orphaned tasks.
- Update language file to match.

* Add demo task routines to stress memory

Adds task routines to test scheduled tasks when either the system memory
runs out or the PHP memory_limit is exceeded.

* Add sleep demo task routine

Renames the first demo task routine and adds a form field to configure
the sleep duration.

* Update language files for plgTaskDemotasks

Adds constants for new task routines and updates some others.

* Cleanup and bugfix com_scheduler

- Removes redundant pass-by-reference
- Makes closures static where possible
- Fixes problematic casts
- Adds some missing parenthesis
- Removes unused variables
- Removes unused method overrides
- Miscellaneous changes

Ref: #35143 / @Denitz

* Improve consistency, extend `#__scheduler_tasks`

Adds `checked_out` and `checkout_out_time` to `#__scheduler_tasks`. Also
adds index for `checked_out`.

Ref: #35143#issuecomment-911819994 / @Denitz

* Remove language autoload from ScheduleRunner

Ref: #35143#issuecomment-911819994 / @Denitz

* Fix missed errant cast

Fixes a leftover problematic cast in IntervalField.

* Patch Task::releaseLock()

The method now updates the Task properties, so they now keep in sync
with db updates and can be used reliably by other code.

* Add plgSystemTaskNotification

This plugin is responsible for sending out email notifications for
task failures and optionally also successful executions.

* Add language files for plgSystemTaskNotifications

* Add SQL DDL for task notification mail templates

* Add auto-install SQL (plgSystemTaskNotifications)

* Add language autoload for plgSysTaskNotification

* Patch auto-install SQL scripts

- Adds installation DDL in installation script (supports.sql)
- Adds the `extension` column in update scripts.

* Cleanup plg taskNotification

* Fix Scheduler::fetchTasks() default behaviour

Shifts the list config for the task queue to the fetchTaskRecord()
method. This makes more sense as the fetchTasks() method is supposed
to be a transparent API method to interact with the TasksModel rather
than have an overriding default like the list.multi_ordering state
variable as a default. Also changes the default ordering behaviour for
sensibility and adds some comments for clarity.

* Add explicit id, title filtering to TasksModel

These are largely redundant to the search filter but convenient to use
and when only the title should be targeted. It turned out I assumed
we had this in the model and so was an outstanding bug with the
Scheduler class. Probably, can use refactor later (or _should_).

* Enhance ExecRuleHelper::nextExec()

Adds a new option $nowBasis argument, when provided uses 'now' as the
last execution. Useful when skipping executions, so we're not actually
updating the last exec.

* Add new Task::Status constant

Adds a status code for when no (matching) task exists.

* Improve comments in the TaskOption class

Improves comment structure, adds some missing punctuation.

* Update the Scheduler class

- Renames fetchTasks() => fetchTaskRecords().
- Fixes broken id search (l190).
- Updates runTask() return (now returns the Task exit code).
- Adds TASK_QUEUE filters and list config as class constants so other
  extensions can reliably use them to get the queue behaviour (should
  this somehow be baked in?).
- Updates return for fetchTaskRecords(), which could return a false
  from the model query before but now would an empty array.

* Bugfix Task::skipExecution()

Now actually skips the execution and advances the task to the next
execution slot relative to 'now'.

* Add scheduler:list console command

Command to list scheduled tasks.

* Add scheduler:run command

Command to run scheduled tasks. Supports triggering the task queue
as well as individual tasks, matching either by id or title. Right now,
due some code-smell fixes and perhaps behavior adjustments. An example,
perhaps the title match could support running all tasks matching a title
with the --all flag.

* Add autoload for new commands

Adds new commands to the application loader and dependency injection
class used by other core commands.

* Add plugin plgTaskCheckFiles

Adds plgTaskCheckFiles. This plugin includes currently a single task
routine which offers the ability to check images in a directory
for dimensions and resize ones that are too big!

* Enhance form for image size routine

Adds sensible defaults, require attributes, etc.

* Update form for get_request routine

Updates the fieldset so its translated right.

* Update language file for com_scheduler

Adds a new constant for the task_params fieldset so plugins can use it
without defining their own.

* Patch task form

Patches the "trigger" field to make it hidden. This is temporary as it
should be removed altogether soon both in the form and the db table.

* Patch exit handling in Task class

The handleExit() method needed the exit code to be passed while it was
available already in the $snapshot class property. This also created
room for error and the final handleExit() return meant that generic
failures were never broadcasted through the failure event.

* Patch exit handling in Task class

The handleExit() method needed the exit code to be passed while it was
available already in the $snapshot class property. This also created
room for error and the final handleExit() return meant that generic
failures were never broadcasted through the failure event.

* Add support for mailing task outputs

Implements support for mailing out task output attachments and
in the body. Not robust but just works for a demo (needs to be
redone).

* Update SQL for task notification templates

Adds the "task_output" param.

* Add output file support in GET request routine

Hastily done and to be redone but this works okay as a POC.

* Patch task class

Fixes the execution time record/next execution which broke somewhere
along before. This is a quick patch and should be fixed as suggested
by the comment.

* Disable deprecated routineEndMessage [CheckFiles]

* Improve code quality, consistency and style

- Removes some redundant comments.
- Reduces reliance on implicit PHP casts.
- Refactors to a more functional approach in TaskModel::save() and calls
  nested within.
- Uses allowed Priority::MAX as plgSystemSchedulerunner listener
  priority.
- Refactors some abbreviated variable names.
- Changes uses of the 'GMT' to 'UTC' (more correct and consistent with
  existing Joomla code)
- Separates some variable assignments and tests for improved
  readability.
- Starts removing imports for native global functions and objects.
  This should be a gradual process.
- Cover up a couple copy-and-paste inconsistencies. oops!
- Reverts a styling regression in old code.

Ref: #35143 / @nibra / @HLeithner / @brianteeman.

* Make SchedulerHelper abstract

Makes SchedulerHelper an abstract class. This also eliminates the need
for a private constructor.

Refs: joomla/joomla-cms/#35143#discussion_r710998565
     / #35143#discussion_r710999157
     / @PhilETaylor
     / @nibra.

* Add request hash protection for scheduler runner

- Adds a configuration tab for the lazy scheduler in ComScheduler with
  configuration switches for disabling the lazy scheduler and protecting
  it with a request hash.
- Adds configuration checks in plgSystemScheduleRunner to only run if
  either hash matches or it's not protected.

* Bugfix scheduleRunner event subscription behaviour

ScheduleRunner attached itself to events even with comScheduler
disabled. This was likely because it utilised a constructor short which
is useful only with the pre-4.x event-method model.
This commit adds checks for the component straight to the
getSubscribedEvents() method and also adds a check for the lazy
scheduler switch in com_scheduler config params.

Refs: @Denitz / #35143#issuecomment-911453500.

* Add rule for manual-only task invocation

Adds an execution rule for when a task should only run when manually
invoked. Also renames internally the "custom" rule to "cron-expression".

* Refactor and extend TaskModel, TaskTable

- Updates TaskModel for changes in the Task form.
- Extends and refactors TaskModel to both support to both support
  the new manual invocation only rule and for better behaviour with
  setting some fields initially in the database.
- Adds a Task::bind() override to TaskTable and changes a default
  param to support updating fields to NULL through AdminModel::save().

* Update ExecRuleHelper

- Update with changes to the Task form.
- Removes imports for native global functions.

* Update language constants for com_scheduler

- Adds language constants for new Scheduler config fields.
- Refactors some language constants for better, more uniform naming.

* Cleanup Task class

- Removes outdated info from handleExit() PHP-doc.
- Removes imports for native global symbols.

* Update com_scheduler manifest

- Adds some missing fields and fixes code-style.

* Apply code-style suggestions from code review

- Fixes styling for some docblocks.
- Fixes copyright header alignment for consistency (non-exhaustive).
- Adds trailing commas for multi-line array declarations (probably non-exhaustive).
- Adds explicit name-spacing for global native symbols (likely non-exhaustive).
- Misc code-style improvements.

Co-authored-by: Phil E. Taylor <phil@phil-taylor.com>

* Apply code-style suggestions from code review

- Fixes styling for some docblocks.
- Fixes copyright header alignment for consistency (non-exhaustive).
- Adds trailing commas for multi-line array declarations (probably non-exhaustive).
- Adds explicit name-spacing for global native symbols (likely non-exhaustive).
- Misc code-style improvements.

Co-authored-by: Phil E. Taylor <phil@phil-taylor.com>

* Clean up usage

* Add AJAX requests script to scheduleRunner

JS sets up a navigator.sendBeacon() callback to make
requests to trigger a `com_ajax` backed AJAX listener offered by
plgSystemScheduleRunner.

* Update manifest for plgSystemScheduleRunner

Adds the new media asset folder, fills in some missing fields and
fixes the language field.

* Add scheduleRunner listener to inject JS

- Removes `shutdown_function` behavior to register the scheduleRunner.
- Adds listener method to inject the trigger JS on the
  `onBeforeCompileHead` event.
- Fixes copyright header styling.
- Reduces event subscription stage check complexity. (Ref: @Denitz /
  joomla-projects/soc21_website-cronjob#4#commitcomment-57308547)
- Adds `com_scheduler` component config as class property.
- Change scheduleRunner's subscription event to `onAjaxRunScheduler`.

* Add scheduleRunner doc and missing checks

- Adds descriptive doc in the class docblock.
- Adds missing checks to the runScheduler() method.

* Fix `created_by` auto set on task save

- TaskTable::save() now sets the `created_by` field  correctly.
- Adds and fixes existing checks for field auto-set.

* Cleanup and enhance TaskTable docs

- Fix copyright style.
- Enhance doc blocks.
- Cleanup.

* Fix plugin manifests

- Lowercase <name>.
- Adds missing fields and missing <files> nodes.
- Fixes XML styling (tasknotification.xml)

Ref: @bembelimen

* Revert changes to the modules/select template

Reverts file to 4.1-dev state.

* Add standard routine handler

`standardRoutineHandler()` can take care of initialising the routine,
calling the associated callable and ending the routine all without
any logic in the plugin class if each routine has a corresponding
callable.

* Fix copyright formatting

* Update Task\Status

Adds status code for invalid return and improves member doc blocks.

* Refactor TaskPluginTrait

- Renames methods:
 - `taskLog()` => `logTask()`
 - `taskEnd()` => `endRoutine()`
 - `taskStart()` => `initRoutine()`
- Upgrade `enhanceTaskItemForm()` to a complete event handler. For
  plugins targeting only the task form, this method can now be mapped
  straight to the `onContentPrepareForm` event.
- Code style improvements and fixes for global namespace qualification
  on some `\Exception` references.
- More explicit checks on variables.
- `Event` type arguments are now `EventInterface` so other
  implementations stay compatible.
- Removes deprecated logging nd `$log` param from `endRoutine()`.

* Improve TaskPluginTrait documentation

Adds and improves on the information in the doc blocks with context,
usage hints and related information. Also updates some parameter
information and fixes the tag order (`@since` <=> `@throws`).

* Implement suggestions on TaskPluginTrait

- Refactors `initRoutine()` => `startRoutine()`
- Return true for irrelevant enhanceTaskItemForm() contexts.
- Path checks for routine forms.
- Allow only class methods with `standardRoutineHandler()`
- Adds signature checks on standard routine methods.
- Adds validation on routine return codes against `Task\Status`.

* Update TaskPluginTrait::standardRoutineHandler()

Now enforces a single required parameter of type `ExecuteTaskEvent`
(from `EventInterface`).

* Update task plugins

- Remove methods now offered by TaskPluginTrait.
- The 'call' TASKS_MAP param is now 'method'.
- Update event subscriptions.
- Update docs.
- Improve code-style and copyright blocks.

* Ignore user aborts on scheduler trigger

Adds attempt to set the INI `ignore_user_abort` to true.
Also enhances some docs.

* Update TaskPluginTrait doc

Updates signature reference for standard routine methods.

* Rename status code

Renames `Task\Status::NO_TIME` to `Task\Status::RUNNING`.

* Add config options for scheduleRunner

Adds config option for the client side request intervals
for the scheduler trigger. Also fixes some showon attributes in
the com_scheduler config form.

* Add removal of time limit on task runs
Add test task permission
Add webcron, test task, lazycron entry points

* Fix broken interval run when setting custom value

* Set correct lazyCron URL and run it at the beginning
Prevent running LazyCron when not in html view or if lazyCron is not enabled
Implement hash check for webCron

* Rebuild JS
Implement test runner

* Finish test cron

* Fix CS

* Revert SQL query

* Add webcron to scheduler config

Updates the `com_scheduler` config.xml with the webcron fieldset.

* Add webcron key autogen and more to Schedulerunner

- Schedulerunner auto-generates the webcron key and does some form
  usability enhancements on the config form (much like the user API
  token plugin).

* Add custom field for webcron link

- Adds new field 'WebcronLinkField', this field is not really needed
  except for to support the custom layout location.
- Allows for the webcron link to be copies on click, much like the user
  API token field.
- Adds field JS to the `com_scheduler` media source provider.

* Update com_scheduler language file

Adds new strings for the config form and updates some refs.

* Fix regression in Scheduler class

- Fix regression due to newly protected status
  of Task::snapshot + accessor.
- Update some doc-blocks and related formatting.
- Optimise some imports.
- Minor miscellaneous changes.

* Fix test run JS

Fixes apparent JS parse error on non-zero task exits.

* Improve form manipulation code

- Check for `com_scheduler` in the subject table for table event.
- Minor code simplification.

* Clean up redundant field from Tasks table

- Remove redundant `trigger` field from `#__scheduler_tasks`.
  - From install and update SQL.
  - Task item form.
  - Language file.
- Fix regression in GenericDataException ref.
- Minor styling/doc fixes and upgrades.

* Remove global task configuration config

- Removes task configuration config from `plgSystemTasknotifications`
  plugin config.
- ! Does not update any usages.

* Add task notification config as injected form

- Task notification config is now injected into the task item form.
- ! Usages are not updated.

* Improve plgSystemTaskNotification code style

- Updates docs.
- Improves docblocks, general code style for compliance with unenforced
  Joomla! style guide.

* Fix params display in task view

* Add fieldset labels for task form

- Adds missing fieldset labels.
- Adds some comments and fixes marginally code-style.

* Update task notification logic

- Replaces checks with updated task item configuration.
- Improves logging (additional checks).
- Makes file attachment handling safer.
- Fixes/updates code-style.

* Update plgSystemTaskNotification language file

- Adds new constants for logging.
- Fixes ordering.

* Fix Task driver behavior

The run() method now updates the object state instead of leaving it
to releaseLock(). The class continues to appear a clunky build :D.

* Fix TasksRunCommand regression

* Fix scheduleRunner default behaviour

- Uses again sensible defaults (enabled lazy cron).
- Check webcron.enabled.
- Some useful logging.
- Improved docblocks.

* Update scheduleRunner language files

Adds new constant for a logging string.

* Update and fix code-style

- Fix license header formatting.
- Fix doc phpdoc tag ordering.
- Cleanup and marginally improve doc-blocks.
- Fix unqualified global refs in doc-blocks.
- Misc formatting fixes/improvements.
- Remove phpcs ignores.

* Revert drone

* Update com_scheduler language file

- Missing constant.
- Ordering.

* Apply suggestions from code review

Code-style and language improvements.

Co-authored-by: Brian Teeman <brian@teeman.net>

* Apply suggestions from code review

Code-style and language improvements.

Co-authored-by: Brian Teeman <brian@teeman.net>

* Update language constants for plgSysScheduleRunner

Updates plugin description string.

* Bugfix Task::run()

For some reason, the UNIX timestamp with microseconds `microtime()`
broke the DateTime breaking down the task usual scheduling.
This commit introduces an int cast for the timestamp which makes things
work as expected.

* Fix webcron url & description

Fixes webcron url and description as exposed in the Scheduler component
config.

Ref: joomla-projects/soc21_website-cronjob#37

* Update joomla.asset.json

* Improve the locking mechanism

* Add table locking when locking task

* CS

* Simplify null date check

* Add column quote

* Extend TaskModel's getter method

! Fails in MySQL 5.6 with "Table <task table> was not locked with LOCK
  TABLES"

- Adds options array to customise behavior.
- Adds static option resolver for proxies to the getter.
- Wrap queue behavior in a sub-query for compatibility.
...

* Update Scheduler::getTask() and runTask()

Updates Scheduler::getTask() and Scheduler::runTask() to match
the updated TaskModel::getTask() method.

* Fix typos and improve static analysis support

Fixes some typos and adds some doc IDE typehint for improved
static analysis to the Scheduler class.

* Update/fix Schedulerunner

Updates primarily the Schedulerunner::runTestCron() method. Other
methods might need to be updated still.

* Update Task class

Minor updates, comments for the future.

* Update Task::releaseLock()

Fixes compatibility with PostgreSQL (tested on 11). Removes table
specificity from columns (this confuses Postgres for some reason).

* Update TaskModel::getTask()

Fixes task queue behavior (now only applies when an ID is not passed).

* Improve TaskModel::getTask() mysql compat

! Still fails because of table locks
- Adds pseudo-source for sub-query.
  https://stackoverflow.com/q/44970574
- Adds reference comments to try to make the
  SQL gymnastics make sense.

* Add unlock function

* Fix language strings for the schedulerunner plugin

* Update description and remove plugin files

* Implement Scheduler CLI state changer

* Update TasksStateCommand.php

* Fix list state filter in scheduler

* Fix MySQL lock violations

Fixes lock violation by getting rid of sub-queries.

* Fix label a11y [#42]

* Quote 'id'

Co-authored-by: Benjamin Trenkle <bembelimen@users.noreply.github.com>

* update publish/unpublish => enable/disable

* Add check for checked out tasks

Adds check for checked out state of tasks, so it doesn't silently fail
anymore if such a task is attempted to be updated.

* Improve static analysis support.

Adds type hints for classes so static analysis and IDE autocomplete
works better.

* Update exit codes and fix typos

- Updates failure exit codes so all are now distinct.
- Fixes typos and other minor things.
- Uses syntactic string composition instead of concatenation.

* Cleanup

Removes debug string eval

* Fix SQL scripts

Reduces length of `#__scheduler_tasks.type` to evade exceeding maximum
length of indices and considering 128 chars is sufficient for a UUID
and for context aware string currently used for routine IDs.

Refs: @HLeithner

* Apply Code-style and doc-block improvements from code review

Co-authored-by: Phil E. Taylor <phil@phil-taylor.com>

* Replace Registry inheritance with composition

Task no longer extends Registry, but uses a new `taskRegistry` property
to store a Registry object. This compositional pattern makes the code
stink less.

* Refactor Task::isSuccess()

No longer takes care of dispatching exit events, which is done by
Task::dispatchExitEvent() now. Return API is unchanged.

* Apply Code-style and doc-block improvements from code review

Co-authored-by: Phil E. Taylor <phil@phil-taylor.com>

* Update doc-blocks for the Task driver

Adds doc-block for Task::EVENTS_MAP and updates the constructor's.

* Update composer.lock

* Update composer.lock

* Make Task property getter public [bug]

Makes the task property getter public. Protected visibility here
breaks things.

* Improve task routine exception handling

- The driver now allows for and preserves exceptions from routines,
throwing them again after wrapping things up and releasing the task
lock.
- Removes the nonNull assertion for the routine snapshot (this already
  did not work).

* Update plgScheduleRunner

Webcron now throws the exception from the task, if it exists. This is
caught by com_ajax and the exception message included in the output.

* Update Task::Status

Renames the KO_RUN status to KNOCKOUT, adds description in docblock.

* Fix exception handling in TaskPluginTrait

Catches only ReflectionExceptions now, leaving out others for the Task
driver to access.

* Cleanup assert exception refs

Cleans up imports and docblocks.

* Improve ScheduleRunner documentation.

* Improve code style

Majorly fixes from the latest updates in Joomla's PHP CS Fixer config,

* Fix demo task form

* Update language file for `com_scheduler`

* Use output buffering for lazyCron to avoid dying

* Merge update SQL

* Update plgTaskCheckfiles

- Adds support for WEBP.
- Better format support while resizing.
- Minor refactoring and more informative logging.

* Update scheduleRunner docs

* Improve code quality for task unlocking

- Improved static analysis support and type-hinting.
- Fix usage of undefined variables.
- Add/modify comments and variable names.
- Update event names and interface for relevance.
- Improve docs in doc-blocks.
- Fix code-style.

* Fix com_scheduler, task plugin code-style

Fixes code-style with the updated php-cs-fixer config.

* Fix WebcronLinkField::getLayoutPaths()

The union operator... did not do the right job.

* Merge more update SQL

Missed one!

* Rename update SQL

Updates date signatures of update files to a fresher date.

* Make plgTaskCheckfiles logging translatable

Adds language constants for logging strings.

Refs: @PhilETaylor

* Update plgTaskRequests

- Add logging on exception.
- Improve variable naming/file write safety.
- Update language file.

Refs: @PhilETaylor

* Improve exception handling plgTaskCheckfiles

- Improves handling exceptions and failures.
- Adds more informative logging.

Refs: @PhilETaylor

* Update code-style and language

- Fixes some misc code-style, reverses regression.
- Adds language for some log.

* Fix installation and update SQL scripts

* Fix update SQL for PostgreSQL for the database checker

* Add new core extensions to the extensions helper

* Add auto-install SQL for plg_task_checkfiles

- Adds auto-install SQL for both installation and update.
- Also adds relevant entry to ExtensionHelper.

Refs: joomla-projects/soc21_website-cronjob#49 / @richard67

* Add DB column for cli exclusive tasks

- Adds new DB column `#__scheduler_tasks.cli_exclusive`, updating both
  install and update scripts. Also adds relevant index.

* Add support for CLI exclusive tasks

- Updates TaskModel::getTask() with an option to include/exclude
  CLI exclusives.
- Adds runtime check to Scheduler::runTask() so it now includes CLI
  exclusives only in a CLI context.

* Add comments, fix doc signatures + style

- Add comments to schedulerunner.
- Fix some type signatures in doc-blocks.
- Other minor style fixes.

* Fix get request response body

Shouldn't throw an undefined constant again.

* Add `Scheduler::run()` option for concurrency

- Scheduler::run() now uses an options array backed by the Symfony
  OptionsResolver.
- Offers a new option that allows for execution concurrency (this was
  specifically required by the CLI command).

* Update plgSystemSchedulerunner

Updates Schedulerunner for changes in Scheduler::run()

* Make `scheduler:run` safer

- Null safety against Tasks.
- More informative stderr log on lock acquisition failures.
- Now allows concurrency so Web doesn't block out CLI anymore (thanks
  to the updates in Scheduler::run()).

Refs: #35143#issuecomment-976391914
      / @alikon
      / @bembelimen

* Refactor `scheduler:state`

- Better (expectedly safer) flow of logic with attempts to get the
  logical/enumerated state from command mode and interactive modes.
- Terminate on invalid command invocation.
- Fix exit success message (did not show action).
- Better formatting of description, etc.
- Code-style fixes.

Refs: #35143#issuecomment-977608144
      / @alikon
      / @bembelimen

* Improve `scheduler:run` description style

Minor improvement to `scheduler:run` description for consistency.

* Add utilities, bugfix Task class

- Adds state enumerations and map.
- Adds basic static state and id validators.
- Fix use of un-imported Text class, $->getMessage() call.

* Improve `scheduler:state` command

- Better validation and improved consistency.
- Removes now redundant state enumerations, mapping and validators
  which the Task class offers.

* Add page reload after testing

* Code sniffer fixes

* Rename param for Scheduler::fetchTaskRecord()

Co-authored-by: Phil E. Taylor <phil@phil-taylor.com>
Co-authored-by: Benjamin Trenkle <benjamin.trenkle@wicked-software.de>
Co-authored-by: Brian Teeman <brian@teeman.net>
Co-authored-by: Benjamin Trenkle <bembelimen@users.noreply.github.com>
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants